Revision 1297:0a574315af3e .svn/pristine/0e

View differences:

.svn/pristine/0e/0e54508d3830a714379a5549a38e89ff26176202.svn-base
1
<h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h2>
2
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
3

  
4
<div id="activity">
5
<% @events_by_day.keys.sort.reverse.each do |day| %>
6
<h3><%= format_activity_day(day) %></h3>
7
<dl>
8
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
9
  <dt class="<%= e.event_type %>  <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
10
  <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>
11
  <span class="time"><%= format_time(e.event_datetime, false) %></span>
12
  <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %>
13
  <%= link_to format_activity_title(e.event_title), e.event_url %></dt>
14
  <dd><span class="description"><%= format_activity_description(e.event_description) %></span>
15
  <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd>
16
<% end -%>
17
</dl>
18
<% end -%>
19
</div>
20

  
21
<%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
22

  
23
<div style="float:left;">
24
<%= link_to_content_update("\xc2\xab " + l(:label_previous),
25
                   params.merge(:from => @date_to - @days - 1),
26
                   :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1))) %>
27
</div>
28
<div style="float:right;">
29
<%= link_to_content_update(l(:label_next) + " \xc2\xbb",
30
                   params.merge(:from => @date_to + @days - 1),
31
                   :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1))) unless @date_to >= Date.today %>
32
</div>
33
&nbsp;
34
<% other_formats_links do |f| %>
35
  <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %>
36
<% end %>
37

  
38
<% content_for :header_tags do %>
39
<%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %>
40
<% end %>
41

  
42
<% content_for :sidebar do %>
43
<%= form_tag({}, :method => :get) do %>
44
<h3><%= l(:label_activity) %></h3>
45
<p><% @activity.event_types.each do |t| %>
46
<%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
47
<label for="show_<%=t%>"><%= link_to(l("label_#{t.singularize}_plural"), {"show_#{t}" => 1, :user_id => params[:user_id]})%></label>
48
<br />
49
<% end %></p>
50
<% if @project && @project.descendants.active.any? %>
51
    <%= hidden_field_tag 'with_subprojects', 0 %>
52
    <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
53
<% end %>
54
<%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
55
<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
56
<% end %>
57
<% end %>
58

  
59
<% html_title(l(:label_activity), @author) -%>
.svn/pristine/0e/0e59eac074a412c3150c3135d0a1eec08baa4fba.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
require File.expand_path('../../test_helper', __FILE__)
19
require 'issues_controller'
20

  
21
class IssuesControllerTransactionTest < ActionController::TestCase
22
  fixtures :projects,
23
           :users,
24
           :roles,
25
           :members,
26
           :member_roles,
27
           :issues,
28
           :issue_statuses,
29
           :versions,
30
           :trackers,
31
           :projects_trackers,
32
           :issue_categories,
33
           :enabled_modules,
34
           :enumerations,
35
           :attachments,
36
           :workflows,
37
           :custom_fields,
38
           :custom_values,
39
           :custom_fields_projects,
40
           :custom_fields_trackers,
41
           :time_entries,
42
           :journals,
43
           :journal_details,
44
           :queries
45

  
46
  self.use_transactional_fixtures = false
47

  
48
  def setup
49
    @controller = IssuesController.new
50
    @request    = ActionController::TestRequest.new
51
    @response   = ActionController::TestResponse.new
52
    User.current = nil
53
  end
54

  
55
  def test_update_stale_issue_should_not_update_the_issue
56
    issue = Issue.find(2)
57
    @request.session[:user_id] = 2
58

  
59
    assert_no_difference 'Journal.count' do
60
      assert_no_difference 'TimeEntry.count' do
61
        put :update,
62
              :id => issue.id,
63
              :issue => {
64
                :fixed_version_id => 4,
65
                :notes => 'My notes',
66
                :lock_version => (issue.lock_version - 1)
67
              },
68
              :time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
69
      end
70
    end
71

  
72
    assert_response :success
73
    assert_template 'edit'
74

  
75
    assert_select 'div.conflict'
76
    assert_select 'input[name=?][value=?]', 'conflict_resolution', 'overwrite'
77
    assert_select 'input[name=?][value=?]', 'conflict_resolution', 'add_notes'
78
    assert_select 'label' do
79
      assert_select 'input[name=?][value=?]', 'conflict_resolution', 'cancel'
80
      assert_select 'a[href=/issues/2]'
81
    end
82
  end
83

  
84
  def test_update_stale_issue_should_save_attachments
85
    set_tmp_attachments_directory
86
    issue = Issue.find(2)
87
    @request.session[:user_id] = 2
88

  
89
    assert_no_difference 'Journal.count' do
90
      assert_no_difference 'TimeEntry.count' do
91
        assert_difference 'Attachment.count' do
92
          put :update,
93
                :id => issue.id,
94
                :issue => {
95
                  :fixed_version_id => 4,
96
                  :notes => 'My notes',
97
                  :lock_version => (issue.lock_version - 1)
98
                },
99
                :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}},
100
                :time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
101
        end
102
      end
103
    end
104

  
105
    assert_response :success
106
    assert_template 'edit'
107
    attachment = Attachment.first(:order => 'id DESC')
108
    assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
109
    assert_tag 'span', :content => /testfile.txt/
110
  end
111

  
112
  def test_update_stale_issue_without_notes_should_not_show_add_notes_option
113
    issue = Issue.find(2)
114
    @request.session[:user_id] = 2
115

  
116
    put :update, :id => issue.id,
117
          :issue => {
118
            :fixed_version_id => 4,
119
            :notes => '',
120
            :lock_version => (issue.lock_version - 1)
121
          }
122

  
123
    assert_tag 'div', :attributes => {:class => 'conflict'}
124
    assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'overwrite'}
125
    assert_no_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'add_notes'}
126
    assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'cancel'}
127
  end
128

  
129
  def test_update_stale_issue_should_show_conflicting_journals
130
    @request.session[:user_id] = 2
131

  
132
    put :update, :id => 1,
133
          :issue => {
134
            :fixed_version_id => 4,
135
            :notes => '',
136
            :lock_version => 2
137
          },
138
          :last_journal_id => 1
139

  
140
    assert_not_nil assigns(:conflict_journals)
141
    assert_equal 1, assigns(:conflict_journals).size
142
    assert_equal 2, assigns(:conflict_journals).first.id
143
    assert_tag 'div', :attributes => {:class => 'conflict'},
144
      :descendant => {:content => /Some notes with Redmine links/}
145
  end
146

  
147
  def test_update_stale_issue_without_previous_journal_should_show_all_journals
148
    @request.session[:user_id] = 2
149

  
150
    put :update, :id => 1,
151
          :issue => {
152
            :fixed_version_id => 4,
153
            :notes => '',
154
            :lock_version => 2
155
          },
156
          :last_journal_id => ''
157

  
158
    assert_not_nil assigns(:conflict_journals)
159
    assert_equal 2, assigns(:conflict_journals).size
160
    assert_tag 'div', :attributes => {:class => 'conflict'},
161
      :descendant => {:content => /Some notes with Redmine links/}
162
    assert_tag 'div', :attributes => {:class => 'conflict'},
163
      :descendant => {:content => /Journal notes/}
164
  end
165

  
166
  def test_update_stale_issue_should_show_private_journals_with_permission_only
167
    journal = Journal.create!(:journalized => Issue.find(1), :notes => 'Privates notes', :private_notes => true, :user_id => 1)
168

  
169
    @request.session[:user_id] = 2
170
    put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => ''
171
    assert_include journal, assigns(:conflict_journals)
172

  
173
    Role.find(1).remove_permission! :view_private_notes
174
    put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => ''
175
    assert_not_include journal, assigns(:conflict_journals)
176
  end
177

  
178
  def test_update_stale_issue_with_overwrite_conflict_resolution_should_update
179
    @request.session[:user_id] = 2
180

  
181
    assert_difference 'Journal.count' do
182
      put :update, :id => 1,
183
            :issue => {
184
              :fixed_version_id => 4,
185
              :notes => 'overwrite_conflict_resolution',
186
              :lock_version => 2
187
            },
188
            :conflict_resolution => 'overwrite'
189
    end
190

  
191
    assert_response 302
192
    issue = Issue.find(1)
193
    assert_equal 4, issue.fixed_version_id
194
    journal = Journal.first(:order => 'id DESC')
195
    assert_equal 'overwrite_conflict_resolution', journal.notes
196
    assert journal.details.any?
197
  end
198

  
199
  def test_update_stale_issue_with_add_notes_conflict_resolution_should_update
200
    @request.session[:user_id] = 2
201

  
202
    assert_difference 'Journal.count' do
203
      put :update, :id => 1,
204
            :issue => {
205
              :fixed_version_id => 4,
206
              :notes => 'add_notes_conflict_resolution',
207
              :lock_version => 2
208
            },
209
            :conflict_resolution => 'add_notes'
210
    end
211

  
212
    assert_response 302
213
    issue = Issue.find(1)
214
    assert_nil issue.fixed_version_id
215
    journal = Journal.first(:order => 'id DESC')
216
    assert_equal 'add_notes_conflict_resolution', journal.notes
217
    assert journal.details.empty?
218
  end
219

  
220
  def test_update_stale_issue_with_cancel_conflict_resolution_should_redirect_without_updating
221
    @request.session[:user_id] = 2
222

  
223
    assert_no_difference 'Journal.count' do
224
      put :update, :id => 1,
225
            :issue => {
226
              :fixed_version_id => 4,
227
              :notes => 'add_notes_conflict_resolution',
228
              :lock_version => 2
229
            },
230
            :conflict_resolution => 'cancel'
231
    end
232

  
233
    assert_redirected_to '/issues/1'
234
    issue = Issue.find(1)
235
    assert_nil issue.fixed_version_id
236
  end
237

  
238
  def test_put_update_with_spent_time_and_failure_should_not_add_spent_time
239
    @request.session[:user_id] = 2
240

  
241
    assert_no_difference('TimeEntry.count') do
242
      put :update,
243
           :id => 1,
244
           :issue => { :subject => '' },
245
           :time_entry => { :hours => '2.5', :comments => 'should not be added', :activity_id => TimeEntryActivity.first.id }
246
      assert_response :success
247
    end
248

  
249
    assert_select 'input[name=?][value=?]', 'time_entry[hours]', '2.5'
250
    assert_select 'input[name=?][value=?]', 'time_entry[comments]', 'should not be added'
251
    assert_select 'select[name=?]', 'time_entry[activity_id]' do
252
      assert_select 'option[value=?][selected=selected]', TimeEntryActivity.first.id
253
    end
254
  end
255

  
256
  def test_index_should_rescue_invalid_sql_query
257
    Query.any_instance.stubs(:statement).returns("INVALID STATEMENT")
258

  
259
    get :index
260
    assert_response 500
261
    assert_tag 'p', :content => /An error occurred/
262
    assert_nil session[:query]
263
    assert_nil session[:issues_index_sort]
264
  end
265
end
.svn/pristine/0e/0e6d154c5ead84b5d126f01a8ce10bcd16d83cbd.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
class WikisController < ApplicationController
19
  menu_item :settings
20
  before_filter :find_project, :authorize
21

  
22
  # Create or update a project's wiki
23
  def edit
24
    @wiki = @project.wiki || Wiki.new(:project => @project)
25
    @wiki.safe_attributes = params[:wiki]
26
    @wiki.save if request.post?
27
  end
28

  
29
  # Delete a project's wiki
30
  def destroy
31
    if request.post? && params[:confirm] && @project.wiki
32
      @project.wiki.destroy
33
      redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'wiki'
34
    end
35
  end
36
end

Also available in: Unified diff