Merge duplicate Spree::User#superadmin? into existing Spree::admin?

This commit is contained in:
Luis Ramos
2020-08-19 09:53:08 +01:00
parent ebf4175662
commit f28241cc5e
3 changed files with 7 additions and 30 deletions

View File

@@ -167,31 +167,16 @@ describe Spree.user_class do
end
end
describe '#superadmin?' do
let(:user) { create(:user) }
context 'when the user has an admin spree role' do
before { user.spree_roles << Spree::Role.create(name: 'admin') }
it 'returns true' do
expect(user.superadmin?).to eq(true)
end
describe '#admin?' do
it 'returns true when the user has an admin spree role' do
expect(create(:admin_user).admin?).to be_truthy
end
context 'when the user does not have an admin spree role' do
it 'returns false' do
expect(user.superadmin?).to eq(false)
end
it 'returns false when the user does not have an admin spree role' do
expect(create(:user).admin?).to eq(false)
end
end
before(:all) { Spree::Role.create name: 'admin' }
it '#admin?' do
expect(create(:admin_user).admin?).to be_truthy
expect(create(:user).admin?).to be_falsey
end
context '#destroy' do
it 'can not delete if it has completed orders' do
order = build(:order, completed_at: Time.zone.now)