From 16dc0a7001ac01ee44a1a191bbc4e6114984aa87 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 17 Sep 2013 12:11:17 -0400 Subject: [PATCH] New user education notification was off by one. Also, remove the "basic" restriction on the "posting too often" message. --- lib/composer_messages_finder.rb | 7 ++----- spec/components/composer_messages_finder_spec.rb | 14 +++++--------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rb index 983081a3aa2..cc40873e327 100644 --- a/lib/composer_messages_finder.rb +++ b/lib/composer_messages_finder.rb @@ -21,7 +21,7 @@ class ComposerMessagesFinder education_key = :education_new_reply end - if count <= SiteSetting.educate_until_posts + if count < SiteSetting.educate_until_posts education_posts_text = I18n.t('education.until_posts', count: SiteSetting.educate_until_posts) return {templateName: 'composer/education', wait_for_typing: true, @@ -56,11 +56,8 @@ class ComposerMessagesFinder # We only care about replies to topics return unless replying? && @details[:topic_id] && - # For users who are not new - @user.has_trust_level?(:basic) && - # And who have posted enough - (@user.post_count > SiteSetting.educate_until_posts) && + (@user.post_count >= SiteSetting.educate_until_posts) && # And who haven't been notified about sequential replies already (!UserHistory.exists_for_user?(@user, :notified_about_sequential_replies)) diff --git a/spec/components/composer_messages_finder_spec.rb b/spec/components/composer_messages_finder_spec.rb index 4945168e6c0..cf6f624783b 100644 --- a/spec/components/composer_messages_finder_spec.rb +++ b/spec/components/composer_messages_finder_spec.rb @@ -28,12 +28,12 @@ describe ComposerMessagesFinder do end it "returns a message for a user who has not posted any topics" do - user.expects(:created_topic_count).returns(10) + user.expects(:created_topic_count).returns(9) finder.check_education_message.should be_present end it "returns no message when the user has posted enough topics" do - user.expects(:created_topic_count).returns(11) + user.expects(:created_topic_count).returns(10) finder.check_education_message.should be_blank end end @@ -46,12 +46,12 @@ describe ComposerMessagesFinder do end it "returns a message for a user who has not posted any topics" do - user.expects(:post_count).returns(10) + user.expects(:post_count).returns(9) finder.check_education_message.should be_present end it "returns no message when the user has posted enough topics" do - user.expects(:post_count).returns(11) + user.expects(:post_count).returns(10) finder.check_education_message.should be_blank end end @@ -129,13 +129,9 @@ describe ComposerMessagesFinder do context "reply" do let(:finder) { ComposerMessagesFinder.new(user, composerAction: 'reply', topic_id: topic.id) } - it "does not give a message to new users" do - user.trust_level = TrustLevel.levels[:newuser] - finder.check_sequential_replies.should be_blank - end it "does not give a message to users who are still in the 'education' phase" do - user.stubs(:post_count).returns(10) + user.stubs(:post_count).returns(9) finder.check_sequential_replies.should be_blank end