Feature #42880 » auto_watch_default_settings.patch
| app/models/user_preference.rb (revision cab88f922c43374247028dae949e731f31e1155f) → app/models/user_preference.rb (revision d7abde0de2bf433125e58e4e3d895428144b38e7) | ||
|---|---|---|
| 59 | 59 | self.no_self_notified = Setting.default_users_no_self_notified | 
| 60 | 60 | end | 
| 61 | 61 | unless attributes && attributes.key?(:auto_watch_on) | 
| 62 | self.auto_watch_on = AUTO_WATCH_ON_OPTIONS | |
| 62 | value = Setting.default_users_auto_watch_on | |
| 63 | self.auto_watch_on = value.nil? ? AUTO_WATCH_ON_OPTIONS : value | |
| 63 | 64 | end | 
| 64 | 65 | end | 
| 65 | 66 |     self.others ||= {} | 
| app/views/settings/_users.html.erb (revision cab88f922c43374247028dae949e731f31e1155f) → app/views/settings/_users.html.erb (revision d7abde0de2bf433125e58e4e3d895428144b38e7) | ||
|---|---|---|
| 20 | 20 |       <p><%= setting_select(:default_notification_option, User.valid_notification_options.collect {|o| [l(o.last), o.first.to_s]}) %></p> | 
| 21 | 21 | <p><%= setting_check_box :default_users_no_self_notified, :label => :label_user_mail_no_self_notified %></p> | 
| 22 | 22 |       <p><%= setting_select :default_users_time_zone, ActiveSupport::TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :label => :field_time_zone, :blank => :label_none %></p> | 
| 23 |       <p><%= setting_multiselect :default_users_auto_watch_on, UserPreference::AUTO_WATCH_ON_OPTIONS.map {|o| [l("label_auto_watch_on_#{o}"), o]}, :label => :label_auto_watch_on %></p> | |
| 23 | 24 | </div> | 
| 24 | 25 | </fieldset> | 
| 25 | 26 | |
| config/settings.yml (revision cab88f922c43374247028dae949e731f31e1155f) → config/settings.yml (revision d7abde0de2bf433125e58e4e3d895428144b38e7) | ||
|---|---|---|
| 287 | 287 | default: 1 | 
| 288 | 288 | default_users_time_zone: | 
| 289 | 289 | default: "" | 
| 290 | default_users_auto_watch_on: | |
| 291 | serialized: true | |
| 292 | default: | |
| 293 | - issue_created | |
| 294 | - issue_contributed_to | |
| 290 | 295 | # encodings used to convert files content to UTF-8 | 
| 291 | 296 | # multiple values accepted, comma separated | 
| 292 | 297 | repositories_encodings: | 
| test/unit/user_preference_test.rb (revision cab88f922c43374247028dae949e731f31e1155f) → test/unit/user_preference_test.rb (revision d7abde0de2bf433125e58e4e3d895428144b38e7) | ||
|---|---|---|
| 56 | 56 | end | 
| 57 | 57 | |
| 58 | 58 | def test_auto_watch_on_should_default_to_setting | 
| 59 | preference = UserPreference.new | |
| 60 | assert_equal %w[issue_created issue_contributed_to], preference.auto_watch_on | |
| 59 | with_settings :default_users_auto_watch_on => ['issue_created'] do | |
| 60 | preference = UserPreference.new | |
| 61 | assert_equal ['issue_created'], preference.auto_watch_on | |
| 62 | end | |
| 63 | with_settings :default_users_auto_watch_on => [] do | |
| 64 | preference = UserPreference.new | |
| 65 | assert_equal [], preference.auto_watch_on | |
| 66 | end | |
| 67 | end | |
| 68 | ||
| 69 | def test_auto_watch_on_should_default_to_options | |
| 70 | with_settings :default_users_auto_watch_on => nil do | |
| 71 | preference = UserPreference.new | |
| 72 | assert_equal %w[issue_created issue_contributed_to], preference.auto_watch_on | |
| 73 | end | |
| 61 | 74 | end | 
| 62 | 75 | |
| 63 | 76 | def test_create |