UX: Remove restrictions on advanced user track.
This commit is contained in:
parent
7028bdceed
commit
18dac4ce9f
|
@ -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
|
def self.reset_trigger
|
||||||
I18n.t('discourse_narrative_bot.advanced_user_narrative.reset_trigger')
|
I18n.t('discourse_narrative_bot.advanced_user_narrative.reset_trigger')
|
||||||
end
|
end
|
||||||
|
|
|
@ -113,7 +113,6 @@ module DiscourseNarrativeBot
|
||||||
end
|
end
|
||||||
|
|
||||||
def selected_track(klass)
|
def selected_track(klass)
|
||||||
return if klass.respond_to?(:can_start?) && !klass.can_start?(@user)
|
|
||||||
post_raw = @post.raw
|
post_raw = @post.raw
|
||||||
trigger = "#{self.class.reset_trigger} #{klass.reset_trigger}"
|
trigger = "#{self.class.reset_trigger} #{klass.reset_trigger}"
|
||||||
|
|
||||||
|
@ -164,14 +163,6 @@ module DiscourseNarrativeBot
|
||||||
end
|
end
|
||||||
|
|
||||||
def help_message
|
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
|
discobot_username = self.discobot_user.username
|
||||||
|
|
||||||
message = I18n.t(
|
message = I18n.t(
|
||||||
|
@ -179,7 +170,7 @@ module DiscourseNarrativeBot
|
||||||
discobot_username: discobot_username,
|
discobot_username: discobot_username,
|
||||||
reset_trigger: self.class.reset_trigger,
|
reset_trigger: self.class.reset_trigger,
|
||||||
default_track: NewUserNarrative.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'),
|
message << "\n\n#{I18n.t(self.class.i18n_key('random_mention.bot_actions'),
|
||||||
|
|
|
@ -25,23 +25,6 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
||||||
SiteSetting.discourse_narrative_bot_enabled = true
|
SiteSetting.discourse_narrative_bot_enabled = true
|
||||||
end
|
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
|
describe '#notify_timeout' do
|
||||||
before do
|
before do
|
||||||
narrative.set_data(user,
|
narrative.set_data(user,
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe DiscourseNarrativeBot::TrackSelector do
|
||||||
discobot_username: discobot_username,
|
discobot_username: discobot_username,
|
||||||
default_track: DiscourseNarrativeBot::NewUserNarrative.reset_trigger,
|
default_track: DiscourseNarrativeBot::NewUserNarrative.reset_trigger,
|
||||||
reset_trigger: described_class.reset_trigger,
|
reset_trigger: described_class.reset_trigger,
|
||||||
tracks: DiscourseNarrativeBot::NewUserNarrative.reset_trigger
|
tracks: "#{DiscourseNarrativeBot::NewUserNarrative.reset_trigger}, #{DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}"
|
||||||
)}
|
)}
|
||||||
|
|
||||||
#{I18n.t(
|
#{I18n.t(
|
||||||
|
@ -178,37 +178,6 @@ describe DiscourseNarrativeBot::TrackSelector do
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue