mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
DEV: Use method instead of constant for discobot badge names
This change refactors the code a bit so that a plugin could easily replace which badge is awarded when completing the discobot new user tutorial and advanced tutorial. By adding a static method and putting the BADGE_NAME constant inside of that method we can simply call that method now instead of the constant. A plugin could then `class_eval` that method and replace it with whatever badge name they choose. This is way cleaner than having the plugin change the frozen constant! eeek.
This commit is contained in:
@ -725,7 +725,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
||||
"topic_id" => topic.id,
|
||||
"track" => described_class.to_s)
|
||||
|
||||
expect(user.badges.where(name: DiscourseNarrativeBot::AdvancedUserNarrative::BADGE_NAME).exists?)
|
||||
expect(user.badges.where(name: DiscourseNarrativeBot::AdvancedUserNarrative.badge_name).exists?)
|
||||
.to eq(true)
|
||||
end
|
||||
end
|
||||
|
@ -1007,7 +1007,7 @@ describe DiscourseNarrativeBot::NewUserNarrative do
|
||||
)
|
||||
|
||||
expect(user.badges.where(
|
||||
name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME).exists?
|
||||
name: DiscourseNarrativeBot::NewUserNarrative.badge_name).exists?
|
||||
).to eq(true)
|
||||
end
|
||||
end
|
||||
|
@ -319,7 +319,7 @@ describe DiscourseNarrativeBot::TrackSelector do
|
||||
)
|
||||
|
||||
BadgeGranter.grant(
|
||||
Badge.find_by(name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME),
|
||||
Badge.find_by(name: DiscourseNarrativeBot::NewUserNarrative.badge_name),
|
||||
user
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user