diff options
| author | Robert | 2017-05-23 09:18:17 +0200 |
|---|---|---|
| committer | Robert | 2017-05-23 09:18:17 +0200 |
| commit | f17e77619409283db7040f270e276813339f919f (patch) | |
| tree | edc920af1b0d71ba751f70949d292c2759c460d7 | |
| parent | 11a65da5faf2936f79b19ef8933595619e521301 (diff) | |
| download | chouette-core-f17e77619409283db7040f270e276813339f919f.tar.bz2 | |
Refs: 3449; Feature spec and implmtn -> fixes #3449
| -rw-r--r-- | app/views/time_tables/show.html.slim | 4 | ||||
| -rw-r--r-- | spec/features/time_tables_permissions_spec.rb | 38 |
2 files changed, 40 insertions, 2 deletions
diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim index 9c40a13a2..9f3004bd4 100644 --- a/app/views/time_tables/show.html.slim +++ b/app/views/time_tables/show.html.slim @@ -15,8 +15,8 @@ /- if policy(@time_table).create? && @referential.organisation == current_organisation = link_to t('actions.combine'), new_referential_time_table_time_table_combination_path(@referential, @time_table), {remote: true, 'data-toggle' => "modal", 'data-target' => '#modal_combine', class: 'btn btn-primary' } - - if policy(@time_table).create? && @referential.organisation == current_organisation - = link_to t('actions.clone'), duplicate_referential_time_table_path(@referential, @time_table), class: 'btn btn-primary' + - if policy(@time_table).duplicate? + = link_to t('actions.duplicate'), duplicate_referential_time_table_path(@referential, @time_table), class: 'btn btn-primary' - if policy(@time_table).destroy? = link_to referential_time_table_path(@referential, @time_table), method: :delete, data: {confirm: t('time_tables.actions.destroy_confirm')}, class: 'btn btn-primary' do diff --git a/spec/features/time_tables_permissions_spec.rb b/spec/features/time_tables_permissions_spec.rb new file mode 100644 index 000000000..bd94a3aa1 --- /dev/null +++ b/spec/features/time_tables_permissions_spec.rb @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +require 'spec_helper' + +describe "TimeTables", :type => :feature do + login_user + + let(:time_table) { create :time_table } + + describe 'permissions' do + before do + allow_any_instance_of(TimeTablePolicy).to receive(:duplicate?).and_return permission + visit path + end + + context 'on show' do + let(:path){ referential_time_table_path(referential, time_table)} + + context "if permission's absent → " do + let(:permission){ false } + + it 'does not show the corresponsing button' do + expect(page).not_to have_link('Dupliquer ce calendrier') + end + end + + context "if permission's present → " do + let(:permission){ true } + + it 'shows the corresponsing button' do + expected_href = duplicate_referential_time_table_path(referential, time_table) + expect(page).to have_link('Dupliquer', href: expected_href) + end + end + end + + end + +end |
