mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: grant badges in post admin wrench (#5498)
* FEATURE: grant badges in post admin wrench * only grant manually grantable badges * extract GrantBadgeController mixin
This commit is contained in:
parent
f26ff290c3
commit
83c549bd31
16 changed files with 229 additions and 55 deletions
|
@ -61,4 +61,23 @@ describe Badge do
|
|||
expect(b.grant_count).to eq(1)
|
||||
end
|
||||
|
||||
describe '#manually_grantable?' do
|
||||
let(:badge) { Fabricate(:badge, name: 'Test Badge') }
|
||||
subject { badge.manually_grantable? }
|
||||
|
||||
context 'when system badge' do
|
||||
before { badge.system = true }
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context 'when has query' do
|
||||
before { badge.query = 'SELECT id FROM users' }
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context 'when neither system nor has query' do
|
||||
before { badge.update_columns(system: false, query: nil) }
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue