Patch #18059 » fixed_bugs_activity.diff
app/models/journal.rb | ||
---|---|---|
25 | 25 |
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all |
26 | 26 |
attr_accessor :indice |
27 | 27 | |
28 |
acts_as_event :title => Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}" },
|
|
28 |
acts_as_event :title => :event_title,
|
|
29 | 29 |
:description => :notes, |
30 | 30 |
:author => :user, |
31 | 31 |
:group => :issue, |
... | ... | |
35 | 35 |
acts_as_activity_provider :type => 'issues', |
36 | 36 |
:author_key => :user_id, |
37 | 37 |
:find_options => {:include => [{:issue => :project}, :details, :user], |
38 |
:conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" + |
|
39 |
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"} |
|
38 |
:conditions => @conditions} |
|
40 | 39 | |
41 | 40 |
before_create :split_private_notes |
42 | 41 |
after_create :send_notification |
... | ... | |
49 | 48 |
where("(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(user, :view_private_notes, *args)}))", false) |
50 | 49 |
} |
51 | 50 | |
51 |
def event_title |
|
52 |
title = title_for_status if !new_status.blank? && new_assigned.blank? |
|
53 |
title = title_for_assigned if new_status.blank? && !new_assigned.blank? |
|
54 |
title = title_for_assigned_and_status if !new_status.blank? && !new_assigned.blank? |
|
55 |
title = "#{l(:text_assigned_to_nobody)}" if title.blank? |
|
56 |
event_conditions |
|
57 |
title |
|
58 |
end |
|
59 | ||
60 |
def event_conditions |
|
61 |
conditions = conditions_for_status if !new_status.blank? && new_assigned.blank? |
|
62 |
conditions = conditions_for_assigned if new_status.blank? && !new_assigned.blank? |
|
63 |
conditions = conditions_for_assigned_and_status if !new_status.blank? && !new_assigned.blank? |
|
64 |
@conditions = conditions |
|
65 |
end |
|
66 | ||
52 | 67 |
def save(*args) |
53 | 68 |
# Do not save an empty journal |
54 | 69 |
(details.empty? && notes.blank?) ? false : super |
... | ... | |
92 | 107 |
s ? IssueStatus.find_by_id(s.to_i) : nil |
93 | 108 |
end |
94 | 109 | |
110 |
def new_assigned |
|
111 |
a = new_value_for('assigned_to_id') |
|
112 |
a ? User.find(a.to_i) : nil |
|
113 |
end |
|
114 | ||
95 | 115 |
def new_value_for(prop) |
96 | 116 |
detail_for_attribute(prop).try(:value) |
97 | 117 |
end |
... | ... | |
196 | 216 |
Mailer.deliver_issue_edit(self) |
197 | 217 |
end |
198 | 218 |
end |
219 | ||
220 |
def title_for_status |
|
221 |
"#{issue.tracker} ##{issue.id} (#{new_status}): #{issue.subject}" |
|
222 |
end |
|
223 | ||
224 |
def title_for_assigned |
|
225 |
"##{issue.id} - #{l(:text_assigned_to)} (#{new_assigned})" |
|
226 |
end |
|
227 | ||
228 |
def title_for_assigned_and_status |
|
229 |
"#{issue.tracker} ##{issue.id} (#{new_status}): #{issue.subject}. #{l(:text_assigned_to)}(#{new_assigned})" |
|
230 |
end |
|
231 | ||
232 |
def conditions_for_status |
|
233 |
"#{Journal.table_name}.journalized_type = 'Issue' AND" + |
|
234 |
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')" |
|
235 |
end |
|
236 | ||
237 |
def conditions_for_assigned |
|
238 |
"#{Journal.table_name}.journalized_type = 'Issue' AND" + |
|
239 |
" (#{JournalDetail.table_name}.prop_key = 'assigned_to_id')" |
|
240 |
end |
|
241 | ||
242 |
def conditions_for_assigned_and_status |
|
243 |
"#{Journal.table_name}.journalized_type = 'Issue' AND" + |
|
244 |
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')" + |
|
245 |
" (#{JournalDetail.table_name}.prop_key = 'assigned_to_id')" |
|
246 |
end |
|
199 | 247 |
end |
config/locales/en.yml | ||
---|---|---|
985 | 985 | |
986 | 986 |
field_active: Active |
987 | 987 | |
988 |
text_assigned_to_nobody: "Now assigned to nobody" |
|
989 |
text_assigned_to: "Now assigned to: " |
|
988 | 990 |
text_select_mail_notifications: Select actions for which email notifications should be sent. |
989 | 991 |
text_regexp_info: eg. ^[A-Z0-9]+$ |
990 | 992 |
text_min_max_length_info: 0 means no restriction |
config/locales/pl.yml | ||
---|---|---|
763 | 763 |
status_active: aktywny |
764 | 764 |
status_locked: zablokowany |
765 | 765 |
status_registered: zarejestrowany |
766 |
text_assigned_to_nobody: "Brak przypisanej osoby" |
|
767 |
text_assigned_to: "Teraz przypisane do: " |
|
766 | 768 |
text_are_you_sure: Jesteś pewien ? |
767 | 769 |
text_assign_time_entries_to_project: Przypisz wpisy dziennika do projektu |
768 | 770 |
text_caracters_maximum: "%{count} znaków maksymalnie." |
test/fixtures/journal_details.yml | ||
---|---|---|
1 | 1 |
--- |
2 |
journal_details_001:
|
|
2 |
journal_details_001: |
|
3 | 3 |
old_value: "1" |
4 | 4 |
property: attr |
5 | 5 |
id: 1 |
6 | 6 |
value: "2" |
7 | 7 |
prop_key: status_id |
8 | 8 |
journal_id: 1 |
9 |
journal_details_002:
|
|
9 |
journal_details_002: |
|
10 | 10 |
old_value: "40" |
11 | 11 |
property: attr |
12 | 12 |
id: 2 |
... | ... | |
41 | 41 |
value: 060719210727_picture.jpg |
42 | 42 |
prop_key: 4 |
43 | 43 |
journal_id: 3 |
44 |
journal_details_007: |
|
45 |
old_value: "1" |
|
46 |
property: attr |
|
47 |
id: 7 |
|
48 |
value: "4" |
|
49 |
prop_key: "status_id" |
|
50 |
journal_id: 6 |
|
51 |
journal_details_008: |
|
52 |
old_value: |
|
53 |
property: attr |
|
54 |
id: 8 |
|
55 |
value: "2" |
|
56 |
prop_key: "assigned_to_id" |
|
57 |
journal_id: 6 |
|
58 |
journal_details_009: |
|
59 |
old_value: "2" |
|
60 |
property: attr |
|
61 |
id: 9 |
|
62 |
value: |
|
63 |
prop_key: "assigned_to_id" |
|
64 |
journal_id: 7 |
|
65 |
journal_details_010: |
|
66 |
old_value: |
|
67 |
property: attr |
|
68 |
id: 10 |
|
69 |
value: "2" |
|
70 |
prop_key: "assigned_to_id" |
|
71 |
journal_id: 8 |
test/fixtures/journals.yml | ||
---|---|---|
34 | 34 |
user_id: 2 |
35 | 35 |
journalized_type: Issue |
36 | 36 |
journalized_id: 14 |
37 |
journals_006: |
|
38 |
id: 6 |
|
39 |
created_on: <%= (Date.today-2).to_date.to_s(:db) %> |
|
40 |
notes: "Change Status And Assigned." |
|
41 |
user_id: 2 |
|
42 |
journalized_type: Issue |
|
43 |
journalized_id: 1 |
|
44 |
journals_007: |
|
45 |
id: 7 |
|
46 |
created_on: <%= Date.today.to_date.to_s(:db) %> |
|
47 |
notes: "Change Assigned to nobody" |
|
48 |
user_id: 2 |
|
49 |
journalized_type: Issue |
|
50 |
journalized_id: 1 |
|
51 |
journals_008: |
|
52 |
id: 8 |
|
53 |
created_on: <%= Date.today.to_date.to_s(:db) %> |
|
54 |
notes: "Change only assigned_to" |
|
55 |
user_id: 2 |
|
56 |
journalized_type: Issue |
|
57 |
journalized_id: 1 |
test/functional/activities_controller_test.rb | ||
---|---|---|
28 | 28 |
:enabled_modules, |
29 | 29 |
:journals, :journal_details |
30 | 30 | |
31 |
def test_edit_issue_with_new_assigned |
|
32 |
get :index, :project_id => 1, :with_subprojects => 0 |
|
33 |
assert_not_nil assigns(:events_by_day) |
|
34 |
# status and assigned_to changed |
|
35 |
assert_select 'a[href=/issues/1#change-6]', :text => "Bug #1 (Feedback): #{ESCAPED_UCANT} print recipes. Now assigned to: (John Smith)" |
|
36 |
# assigned_to changed on nobody |
|
37 |
assert_select 'a[href=/issues/1#change-7]', :text => "Now assigned to nobody" |
|
38 |
# assigned_to changed on 2 |
|
39 |
assert_select 'a[href=/issues/1#change-8]', :text => "#1 - Now assigned to: (John Smith)" |
|
40 |
end |
|
31 | 41 | |
32 | 42 |
def test_project_index |
33 | 43 |
get :index, :id => 1, :with_subprojects => 0 |
test/functional/issues_controller_transaction_test.rb | ||
---|---|---|
136 | 136 |
:last_journal_id => 1 |
137 | 137 | |
138 | 138 |
assert_not_nil assigns(:conflict_journals) |
139 |
assert_equal 1, assigns(:conflict_journals).size
|
|
139 |
assert_equal 4, assigns(:conflict_journals).size
|
|
140 | 140 |
assert_equal 2, assigns(:conflict_journals).first.id |
141 | 141 |
assert_tag 'div', :attributes => {:class => 'conflict'}, |
142 | 142 |
:descendant => {:content => /Some notes with Redmine links/} |
... | ... | |
154 | 154 |
:last_journal_id => '' |
155 | 155 | |
156 | 156 |
assert_not_nil assigns(:conflict_journals) |
157 |
assert_equal 2, assigns(:conflict_journals).size
|
|
157 |
assert_equal 5, assigns(:conflict_journals).size
|
|
158 | 158 |
assert_tag 'div', :attributes => {:class => 'conflict'}, |
159 | 159 |
:descendant => {:content => /Some notes with Redmine links/} |
160 | 160 |
assert_tag 'div', :attributes => {:class => 'conflict'}, |
test/unit/issue_test.rb | ||
---|---|---|
2266 | 2266 |
end |
2267 | 2267 | |
2268 | 2268 |
def test_last_journal_id_with_journals_should_return_the_journal_id |
2269 |
assert_equal 2, Issue.find(1).last_journal_id
|
|
2269 |
assert_equal 8, Issue.find(1).last_journal_id
|
|
2270 | 2270 |
end |
2271 | 2271 | |
2272 | 2272 |
def test_last_journal_id_without_journals_should_return_nil |
... | ... | |
2274 | 2274 |
end |
2275 | 2275 | |
2276 | 2276 |
def test_journals_after_should_return_journals_with_greater_id |
2277 |
assert_equal [Journal.find(2)], Issue.find(1).journals_after('1')
|
|
2278 |
assert_equal [], Issue.find(1).journals_after('2')
|
|
2277 |
assert_equal Journal.find(2,6,7,8), Issue.find(1).journals_after('1')
|
|
2278 |
assert_equal Journal.find(6,7,8), Issue.find(1).journals_after('2')
|
|
2279 | 2279 |
end |
2280 | 2280 | |
2281 | 2281 |
def test_journals_after_with_blank_arg_should_return_all_journals |
2282 |
assert_equal [Journal.find(1), Journal.find(2)], Issue.find(1).journals_after('')
|
|
2282 |
assert_equal Journal.find(1,2,6,7,8), Issue.find(1).journals_after('')
|
|
2283 | 2283 |
end |
2284 | 2284 | |
2285 | 2285 |
def test_css_classes_should_include_tracker |
- « Previous
- 1
- …
- 4
- 5
- 6
- Next »