Feature #2716 » 0001-Add-option-to-auto-watch-issues-assigned-to-me.patch
| app/models/journal.rb | ||
|---|---|---|
| 335 | 335 |
!Watcher.any_watched?(Array.wrap(journalized), user) |
| 336 | 336 |
journalized.set_watcher(user, true) |
| 337 | 337 |
end |
| 338 | ||
| 339 |
if journalized.assigned_to && |
|
| 340 |
journalized.assigned_to.pref.auto_watch_on?('issue_assigned_to_me') &&
|
|
| 341 |
!Watcher.any_watched?(Array.wrap(journalized), journalized.assigned_to) |
|
| 342 |
journalized.set_watcher(journalized.assigned_to, true) |
|
| 343 |
end |
|
| 338 | 344 |
end |
| 339 | 345 | |
| 340 | 346 |
def send_notification |
| app/models/user_preference.rb | ||
|---|---|---|
| 44 | 44 | |
| 45 | 45 |
TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional'] |
| 46 | 46 |
DEFAULT_TOOLBAR_LANGUAGE_OPTIONS = %w[c cpp csharp css diff go groovy html java javascript objc perl php python r ruby sass scala shell sql swift xml yaml] |
| 47 |
AUTO_WATCH_ON_OPTIONS = ['issue_contributed_to'] |
|
| 47 |
AUTO_WATCH_ON_OPTIONS = ['issue_contributed_to', 'issue_assigned_to_me']
|
|
| 48 | 48 | |
| 49 | 49 |
def initialize(attributes=nil, *args) |
| 50 | 50 |
super |
| config/locales/en.yml | ||
|---|---|---|
| 958 | 958 |
label_add_another_file: Add another file |
| 959 | 959 |
label_auto_watch_on: Auto watch |
| 960 | 960 |
label_auto_watch_on_issue_contributed_to: Issues I contributed to |
| 961 |
label_auto_watch_on_issue_assigned_to_me: Issues assigned to me |
|
| 961 | 962 |
label_preferences: Preferences |
| 962 | 963 |
label_chronological_order: In chronological order |
| 963 | 964 |
label_reverse_chronological_order: In reverse chronological order |
| test/unit/journal_test.rb | ||
|---|---|---|
| 120 | 120 |
end |
| 121 | 121 |
end |
| 122 | 122 | |
| 123 |
def test_create_should_add_wacher |
|
| 123 |
def test_create_should_add_watcher
|
|
| 124 | 124 |
user = User.first |
| 125 | 125 |
user.pref.auto_watch_on=['issue_contributed_to'] |
| 126 | 126 |
user.save |
| ... | ... | |
| 142 | 142 |
end |
| 143 | 143 |
end |
| 144 | 144 | |
| 145 |
def test_create_should_add_assignee_as_watcher |
|
| 146 |
user = User.find(2) |
|
| 147 |
user.pref.auto_watch_on=['issue_assigned_to_me'] |
|
| 148 |
user.save |
|
| 149 | ||
| 150 |
issue = Issue.find(2) |
|
| 151 |
issue.assigned_to = user |
|
| 152 |
issue.save |
|
| 153 | ||
| 154 |
journal = Journal.new(:journalized => issue, :notes => 'notes', :user => user) |
|
| 155 | ||
| 156 |
assert_difference 'Watcher.count', 1 do |
|
| 157 |
assert_equal true, journal.save |
|
| 158 |
end |
|
| 159 |
end |
|
| 160 | ||
| 161 |
def test_create_should_not_add_assignee_as_watcher |
|
| 162 |
user = User.find(2) |
|
| 163 |
user.pref.auto_watch_on=[] |
|
| 164 |
user.save |
|
| 165 | ||
| 166 |
issue = Issue.find(2) |
|
| 167 |
issue.assigned_to = user |
|
| 168 |
issue.save |
|
| 169 | ||
| 170 |
journal = Journal.new(:journalized => issue, :notes => 'notes', :user => user) |
|
| 171 | ||
| 172 |
assert_no_difference 'Watcher.count' do |
|
| 173 |
assert_equal true, journal.save |
|
| 174 |
end |
|
| 175 |
end |
|
| 176 | ||
| 145 | 177 |
def test_visible_scope_for_anonymous |
| 146 | 178 |
# Anonymous user should see issues of public projects only |
| 147 | 179 |
journals = Journal.visible(User.anonymous).to_a |
| test/unit/user_preference_test.rb | ||
|---|---|---|
| 59 | 59 | |
| 60 | 60 |
def test_auto_watch_on_should_default_to_setting |
| 61 | 61 |
preference = UserPreference.new |
| 62 |
assert_equal ['issue_contributed_to'], preference.auto_watch_on |
|
| 62 |
assert_equal ['issue_contributed_to', 'issue_assigned_to_me'], preference.auto_watch_on
|
|
| 63 | 63 |
end |
| 64 | 64 | |
| 65 | 65 |
def test_create |