diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/advanced_user_narrative.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/advanced_user_narrative.rb index c9030d762d6..1c3b67f520c 100644 --- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/advanced_user_narrative.rb +++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/advanced_user_narrative.rb @@ -95,11 +95,6 @@ module DiscourseNarrativeBot } } - def self.can_start?(user) - return true if user.staff? || !SiteSetting.enable_badges - user.badges.where(name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME).exists? - end - def self.reset_trigger I18n.t('discourse_narrative_bot.advanced_user_narrative.reset_trigger') end diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/track_selector.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/track_selector.rb index 5540afd2028..94fdfd9f831 100644 --- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/track_selector.rb +++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/track_selector.rb @@ -113,7 +113,6 @@ module DiscourseNarrativeBot end def selected_track(klass) - return if klass.respond_to?(:can_start?) && !klass.can_start?(@user) post_raw = @post.raw trigger = "#{self.class.reset_trigger} #{klass.reset_trigger}" @@ -164,14 +163,6 @@ module DiscourseNarrativeBot end def help_message - tracks = [NewUserNarrative.reset_trigger] - - if @user.staff? || - @user.badges.where(name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME).exists? - - tracks << AdvancedUserNarrative.reset_trigger - end - discobot_username = self.discobot_user.username message = I18n.t( @@ -179,7 +170,7 @@ module DiscourseNarrativeBot discobot_username: discobot_username, reset_trigger: self.class.reset_trigger, default_track: NewUserNarrative.reset_trigger, - tracks: tracks.join(', ') + tracks: [NewUserNarrative.reset_trigger, AdvancedUserNarrative.reset_trigger].join(', ') ) message << "\n\n#{I18n.t(self.class.i18n_key('random_mention.bot_actions'), diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb index 63f2a031e4c..9eb72486364 100644 --- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb +++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb @@ -25,23 +25,6 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do SiteSetting.discourse_narrative_bot_enabled = true end - describe '.can_start?' do - describe 'when user is a moderator' do - it 'should return true' do - user.update!(moderator: true) - - expect(described_class.can_start?(user)).to eq(true) - end - end - - describe 'when badges are disabled' do - it 'should return true' do - SiteSetting.enable_badges = false - expect(described_class.can_start?(user)).to eq(true) - end - end - end - describe '#notify_timeout' do before do narrative.set_data(user, diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb index 4681e7e4703..2b9237d20c0 100644 --- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb +++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb @@ -21,7 +21,7 @@ describe DiscourseNarrativeBot::TrackSelector do discobot_username: discobot_username, default_track: DiscourseNarrativeBot::NewUserNarrative.reset_trigger, reset_trigger: described_class.reset_trigger, - tracks: DiscourseNarrativeBot::NewUserNarrative.reset_trigger + tracks: "#{DiscourseNarrativeBot::NewUserNarrative.reset_trigger}, #{DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}" )} #{I18n.t( @@ -178,37 +178,6 @@ describe DiscourseNarrativeBot::TrackSelector do end end end - - context 'start/reset advanced track' do - before do - post.update!( - raw: "@#{discobot_user.username} #{described_class.reset_trigger} #{DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}" - ) - end - - context 'when new user track has not been completed' do - it 'should not start the track' do - described_class.new(:reply, user, post_id: post.id).select - - expect(DiscourseNarrativeBot::Store.get(user.id)['track']) - .to eq(DiscourseNarrativeBot::NewUserNarrative.to_s) - end - end - - context 'when new user track has been completed' do - it 'should start the track' do - BadgeGranter.grant( - Badge.find_by(name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME), - user - ) - - described_class.new(:reply, user, post_id: post.id).select - - expect(DiscourseNarrativeBot::Store.get(user.id)['track']) - .to eq(DiscourseNarrativeBot::AdvancedUserNarrative.to_s) - end - end - end end end