UX: Remove restrictions on advanced user track.

This commit is contained in:
Guo Xiang Tan 2017-05-26 11:05:09 +08:00
parent 7028bdceed
commit 18dac4ce9f
4 changed files with 2 additions and 64 deletions

View File

@ -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

View File

@ -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'),

View File

@ -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,

View File

@ -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