Project

General

Profile

Feature #21503 » Email_Self_Notification_Setting.diff

Mike Sweetman, 2016-01-12 05:42

View differences:

app/models/user_preference.rb (working copy)
25 25

  
26 26
  def initialize(attributes=nil, *args)
27 27
    super
28
    if new_record? && !(attributes && attributes.key?(:hide_mail))
29
      self.hide_mail = Setting.default_users_hide_mail?
28
    if new_record?
29
      if !(attributes && attributes.key?(:hide_mail))
30
        self.hide_mail = Setting.default_users_hide_mail?
31
      end
32
      if !(attributes && attributes.key?(:no_self_notified))
33
        self.no_self_notified = !Setting.default_users_self_notification?
34
      end
30 35
    end
31 36
    self.others ||= {}
32 37
  end
app/views/settings/_authentication.html.erb (working copy)
41 41

  
42 42
  <div class="tabular settings">
43 43
    <p><%= setting_check_box :default_users_hide_mail, :label => :field_hide_mail %></p>
44
    <p><%= setting_check_box :default_users_self_notification, :label => :field_self_notification %></p>
44 45
  </div>
45 46
</fieldset>
46 47

  
config/locales/en.yml (working copy)
295 295
  field_done_ratio: "% Done"
296 296
  field_auth_source: Authentication mode
297 297
  field_hide_mail: Hide my email address
298
  field_self_notification: Email self notification
298 299
  field_comments: Comment
299 300
  field_url: URL
300 301
  field_start_page: Start page
config/settings.yml (working copy)
219 219
# multiple values accepted, comma separated
220 220
default_users_hide_mail:
221 221
  default: 1
222
default_users_self_notification:
223
  default: 1
222 224
repositories_encodings:
223 225
  default: ''
224 226
# encoding used to convert commit logs to UTF-8
test/unit/user_preference_test.rb (working copy)
32 32
    end
33 33
  end
34 34

  
35
  def test_self_notification_should_default_to_true
36
    preference = UserPreference.new
37
    assert_equal true, preference.self_notification
38
  end
39

  
40
  def test_self_notification_should_default_to_false_with_setting
41
    with_settings :default_users_self_notification => '0' do
42
      preference = UserPreference.new
43
      assert_equal false, preference.self_notification
44
    end
45
  end
46

  
35 47
  def test_create
36 48
    user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
37 49
    user.login = "newuser"
(2-2/2)