diff options
| author | Vlatka Pavisic | 2017-01-23 14:48:46 +0100 |
|---|---|---|
| committer | Vlatka Pavisic | 2017-01-23 14:48:46 +0100 |
| commit | 39887727b818815f002d9fb6c28344e2b50ce209 (patch) | |
| tree | 35a318c9d4193f09db04c12ce8d6af581b6808c2 /spec/features/time_tables_spec.rb | |
| parent | ed75c7827615d0ae58202212189dbfbbf4b92609 (diff) | |
| download | chouette-core-39887727b818815f002d9fb6c28344e2b50ce209.tar.bz2 | |
Refs #2428 #2427 : User permissions
Diffstat (limited to 'spec/features/time_tables_spec.rb')
| -rw-r--r-- | spec/features/time_tables_spec.rb | 107 |
1 files changed, 101 insertions, 6 deletions
diff --git a/spec/features/time_tables_spec.rb b/spec/features/time_tables_spec.rb index 9b99ad8a3..de0d33a9d 100644 --- a/spec/features/time_tables_spec.rb +++ b/spec/features/time_tables_spec.rb @@ -5,24 +5,119 @@ describe "TimeTables", :type => :feature do login_user let!(:time_tables) { Array.new(2) { create(:time_table) } } + let(:time_table) { time_tables.first } subject { time_tables.first } - describe "list" do - it "display time_tables" do - visit referential_time_tables_path(referential) + describe "index" do + before(:each) { visit referential_time_tables_path(referential) } + + it "displays time_tables" do expect(page).to have_content(time_tables.first.comment) expect(page).to have_content(time_tables.last.comment) end + context 'user has permission to create time tables' do + it 'shows a create link for time tables' do + expect(page).to have_content(I18n.t('time_tables.actions.new')) + end + end + + context 'user does not have permission to create time tables' do + it 'does not show a create link for time tables' do + @user.update_attribute(:permissions, []) + visit referential_time_tables_path(referential) + expect(page).not_to have_content(I18n.t('time_tables.actions.new')) + end + end + + context 'user has permission to edit time tables' do + it 'shows an edit button for time tables' do + expect(page).to have_css('span.fa.fa-pencil') + end + end + + context 'user does not have permission to edit time tables' do + it 'does not show a edit link for time tables' do + @user.update_attribute(:permissions, []) + visit referential_time_tables_path(referential) + expect(page).not_to have_css('span.fa.fa-pencil') + end + end + + context 'user has permission to destroy time tables' do + it 'shows a destroy button for time tables' do + expect(page).to have_css('span.fa.fa-trash-o') + end + end + + context 'user does not have permission to destroy time tables' do + it 'does not show a destroy button for time tables' do + @user.update_attribute(:permissions, []) + visit referential_time_tables_path(referential) + expect(page).not_to have_css('span.fa.fa-trash-o') + end + end + end describe "show" do - it "display time_table" do - visit referential_time_tables_path(referential) - click_link "#{time_tables.first.comment}" + before(:each) { visit referential_time_table_path(referential, time_table) } + + it "displays time_table" do expect(page).to have_content(time_tables.first.comment) end + context 'user has permission to create time tables' do + it 'shows a create link for time tables' do + expect(page).to have_content(I18n.t('time_tables.actions.new')) + end + + it 'does not show link to duplicate the time table' do + expect(page).to have_content(I18n.t('time_tables.actions.duplicate')) + end + end + + context 'user does not have permission to create time tables' do + it 'does not show a create link for time tables' do + @user.update_attribute(:permissions, []) + visit referential_time_table_path(referential, time_table) + expect(page).not_to have_content(I18n.t('time_tables.actions.new')) + end + + it 'does not show link to duplicate the time table' do + @user.update_attribute(:permissions, []) + visit referential_time_table_path(referential, time_table) + expect(page).not_to have_content(I18n.t('time_tables.actions.duplicate')) + end + end + + context 'user has permission to edit time tables' do + it 'shows the edit link for time table' do + expect(page).to have_content(I18n.t('time_tables.actions.edit')) + end + end + + context 'user does not have permission to edit time tables' do + it 'does not show the edit link for time table' do + @user.update_attribute(:permissions, []) + visit referential_time_table_path(referential, time_table) + expect(page).not_to have_content(I18n.t('time_tables.actions.edit')) + end + end + + context 'user has permission to destroy time tables' do + it 'shows the destroy link for time table' do + expect(page).to have_content(I18n.t('time_tables.actions.destroy')) + end + end + + context 'user does not have permission to destroy time tables' do + it 'does not show a destroy link for time table' do + @user.update_attribute(:permissions, []) + visit referential_time_table_path(referential, time_table) + expect(page).not_to have_content(I18n.t('time_tables.actions.destroy')) + end + end end describe "new" do |
