diff options
| author | Luc Donnet | 2018-04-21 16:37:32 +0200 |
|---|---|---|
| committer | Luc Donnet | 2018-04-22 21:18:40 +0200 |
| commit | 2fdcaca3a0302d35aa007c3dd309fb42a3c7e536 (patch) | |
| tree | 2bd41cb5bc40d067b569596d05956744d6be7ce2 /spec | |
| parent | 02c4483c1d0d763af8c7dd44335577f60d43cc40 (diff) | |
| download | chouette-core-2fdcaca3a0302d35aa007c3dd309fb42a3c7e536.tar.bz2 | |
Fix views spec for line_referential and stop_area referential synchronization Refs #6306 @1
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/features/line_referentials_permissions_spec.rb | 30 | ||||
| -rw-r--r-- | spec/features/stop_area_referentials_permissions_spec.rb | 30 | ||||
| -rw-r--r-- | spec/policies/stop_area_referential_policy_spec.rb (renamed from spec/policies/sto_area_referential_policy_spec.rb) | 0 |
3 files changed, 60 insertions, 0 deletions
diff --git a/spec/features/line_referentials_permissions_spec.rb b/spec/features/line_referentials_permissions_spec.rb new file mode 100644 index 000000000..845ffe9c1 --- /dev/null +++ b/spec/features/line_referentials_permissions_spec.rb @@ -0,0 +1,30 @@ +RSpec.describe 'LineReferentials', type: :feature do + login_user + + let(:line_referential) { first_workgroup.line_referential } + + describe 'permissions' do + before do + allow_any_instance_of(LineReferentialPolicy).to receive(:synchronize?).and_return permission + visit path + end + + context 'on show view' do + let( :path ){ line_referential_path(line_referential.id) } + + context 'if present → ' do + let( :permission ){ true } + it 'shows an edit button' do + expect(page).to have_css('a.btn.btn-default', text: I18n.t('actions.sync')) + end + end + + context 'if absent → ' do + let( :permission ){ false } + it 'does not show any edit button' do + expect(page).not_to have_css('a.btn.btn-default', text: I18n.t('actions.sync')) + end + end + end + end +end diff --git a/spec/features/stop_area_referentials_permissions_spec.rb b/spec/features/stop_area_referentials_permissions_spec.rb new file mode 100644 index 000000000..ca7038d51 --- /dev/null +++ b/spec/features/stop_area_referentials_permissions_spec.rb @@ -0,0 +1,30 @@ +RSpec.describe 'StopAreaReferentials', type: :feature do + login_user + + let(:stop_area_referential) { first_workgroup.stop_area_referential } + + describe 'permissions' do + before do + allow_any_instance_of(StopAreaReferentialPolicy).to receive(:synchronize?).and_return permission + visit path + end + + context 'on show view' do + let( :path ){ stop_area_referential_path(stop_area_referential.id) } + + context 'if present → ' do + let( :permission ){ true } + it 'shows an edit button' do + expect(page).to have_css('a.btn.btn-default', text: I18n.t('actions.sync')) + end + end + + context 'if absent → ' do + let( :permission ){ false } + it 'does not show any edit button' do + expect(page).not_to have_css('a.btn.btn-default', text: I18n.t('actions.sync')) + end + end + end + end +end diff --git a/spec/policies/sto_area_referential_policy_spec.rb b/spec/policies/stop_area_referential_policy_spec.rb index 5bd6da427..5bd6da427 100644 --- a/spec/policies/sto_area_referential_policy_spec.rb +++ b/spec/policies/stop_area_referential_policy_spec.rb |
