Skip to content

Commit

Permalink
Fix availability testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdonarski committed Oct 13, 2023
1 parent da734e3 commit 528e130
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions spec/models/spree/admin/actions/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ module Admin
name: 'Cart',
url: '/cart',
classes: 'nav-link',
availability_checks: availability_checks,
method: :put,
id: 'admin_new_order',
target: :blank,
data: { turbo: false }
}
end
let(:availability_checks) { [] }

describe '#icon_name' do
subject { action.icon_name }
Expand Down Expand Up @@ -87,25 +89,25 @@ module Admin
let(:ability) { double }
let(:resource) { double }

context 'when availability check is not set' do
context 'when availability checks were not set' do
it 'is returns true' do
expect(subject).to be(true)
end
end

context 'when availability check returns true' do
before do
action.with_availability_check(->(_ability, _resource) { true })
context 'when all availability checks return true' do
let(:availability_checks) do
[->(_ability, _resource) { true }]
end

it 'returns true' do
expect(subject).to be(true)
end
end

context 'when availability check returns false' do
before do
action.with_availability_check(->(_ability, _resource) { false })
context 'when at least one availability check returns false' do
let(:availability_checks) do
[->(_ability, _resource) { false }]
end

it 'returns false' do
Expand Down

0 comments on commit 528e130

Please sign in to comment.