Feature #2716 » 0001-Add-option-to-auto-watch-issues-assigned-to-me.patch
| app/models/journal.rb | ||
|---|---|---|
|
!Watcher.any_watched?(Array.wrap(journalized), user)
|
||
|
journalized.set_watcher(user, true)
|
||
|
end
|
||
|
if journalized.assigned_to &&
|
||
|
journalized.assigned_to.pref.auto_watch_on?('issue_assigned_to_me') &&
|
||
|
!Watcher.any_watched?(Array.wrap(journalized), journalized.assigned_to)
|
||
|
journalized.set_watcher(journalized.assigned_to, true)
|
||
|
end
|
||
|
end
|
||
|
def send_notification
|
||
| app/models/user_preference.rb | ||
|---|---|---|
|
TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional']
|
||
|
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]
|
||
|
AUTO_WATCH_ON_OPTIONS = ['issue_contributed_to']
|
||
|
AUTO_WATCH_ON_OPTIONS = ['issue_contributed_to', 'issue_assigned_to_me']
|
||
|
def initialize(attributes=nil, *args)
|
||
|
super
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_add_another_file: Add another file
|
||
|
label_auto_watch_on: Auto watch
|
||
|
label_auto_watch_on_issue_contributed_to: Issues I contributed to
|
||
|
label_auto_watch_on_issue_assigned_to_me: Issues assigned to me
|
||
|
label_preferences: Preferences
|
||
|
label_chronological_order: In chronological order
|
||
|
label_reverse_chronological_order: In reverse chronological order
|
||
| test/unit/journal_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_create_should_add_wacher
|
||
|
def test_create_should_add_watcher
|
||
|
user = User.first
|
||
|
user.pref.auto_watch_on=['issue_contributed_to']
|
||
|
user.save
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def test_create_should_add_assignee_as_watcher
|
||
|
user = User.find(2)
|
||
|
user.pref.auto_watch_on=['issue_assigned_to_me']
|
||
|
user.save
|
||
|
issue = Issue.find(2)
|
||
|
issue.assigned_to = user
|
||
|
issue.save
|
||
|
journal = Journal.new(:journalized => issue, :notes => 'notes', :user => user)
|
||
|
assert_difference 'Watcher.count', 1 do
|
||
|
assert_equal true, journal.save
|
||
|
end
|
||
|
end
|
||
|
def test_create_should_not_add_assignee_as_watcher
|
||
|
user = User.find(2)
|
||
|
user.pref.auto_watch_on=[]
|
||
|
user.save
|
||
|
issue = Issue.find(2)
|
||
|
issue.assigned_to = user
|
||
|
issue.save
|
||
|
journal = Journal.new(:journalized => issue, :notes => 'notes', :user => user)
|
||
|
assert_no_difference 'Watcher.count' do
|
||
|
assert_equal true, journal.save
|
||
|
end
|
||
|
end
|
||
|
def test_visible_scope_for_anonymous
|
||
|
# Anonymous user should see issues of public projects only
|
||
|
journals = Journal.visible(User.anonymous).to_a
|
||
| test/unit/user_preference_test.rb | ||
|---|---|---|
|
def test_auto_watch_on_should_default_to_setting
|
||
|
preference = UserPreference.new
|
||
|
assert_equal ['issue_contributed_to'], preference.auto_watch_on
|
||
|
assert_equal ['issue_contributed_to', 'issue_assigned_to_me'], preference.auto_watch_on
|
||
|
end
|
||
|
def test_create
|
||