From 470da6205c36d83daa32c8403d0d0bf886e5f0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 14 Jun 2016 16:45:47 +0200 Subject: [PATCH] FIX: staged users should not watch/track/mute categories by default --- app/models/user.rb | 2 ++ app/models/user_option.rb | 1 - spec/models/user_spec.rb | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index bff29252386..c44a6fd3a5d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -952,6 +952,8 @@ class User < ActiveRecord::Base end def set_default_categories_preferences + return if self.staged? + values = [] %w{watching tracking muted}.each do |s| diff --git a/app/models/user_option.rb b/app/models/user_option.rb index 6f0a8ecbdc6..7a812e4033f 100644 --- a/app/models/user_option.rb +++ b/app/models/user_option.rb @@ -42,7 +42,6 @@ class UserOption < ActiveRecord::Base self.like_notification_frequency = SiteSetting.default_other_like_notification_frequency - if SiteSetting.default_email_digest_frequency.to_i <= 0 self.email_digests = false else diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4fbd120a68a..e08759b6d97 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1235,6 +1235,13 @@ describe User do expect(CategoryUser.lookup(user, :tracking).pluck(:category_id)).to eq([2]) expect(CategoryUser.lookup(user, :muted).pluck(:category_id)).to eq([3]) end + + it "does not set category preferences for staged users" do + user = Fabricate(:user, staged: true) + expect(CategoryUser.lookup(user, :watching).pluck(:category_id)).to eq([]) + expect(CategoryUser.lookup(user, :tracking).pluck(:category_id)).to eq([]) + expect(CategoryUser.lookup(user, :muted).pluck(:category_id)).to eq([]) + end end context UserOption do