diff options
| author | cedricnjanga | 2018-03-05 18:55:31 -0800 | 
|---|---|---|
| committer | cedricnjanga | 2018-03-09 08:48:56 -0800 | 
| commit | a26a2e98b9552467d4a92ad6b5be22c3f3070efa (patch) | |
| tree | 93a0cfd5e857bdb87a15bc8ad15034bbab234e74 /spec/features/routes_spec.rb | |
| parent | 5d4be9c520768563a79414c73829ab10eae52434 (diff) | |
| download | chouette-core-a26a2e98b9552467d4a92ad6b5be22c3f3070efa.tar.bz2 | |
Refs #5934 Add specs to routes spec feature
Diffstat (limited to 'spec/features/routes_spec.rb')
| -rw-r--r-- | spec/features/routes_spec.rb | 49 | 
1 files changed, 49 insertions, 0 deletions
| diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb index 3bd2071d2..dbab2c0d2 100644 --- a/spec/features/routes_spec.rb +++ b/spec/features/routes_spec.rb @@ -6,6 +6,7 @@ describe "Routes", :type => :feature do    let!(:route2) { create(:route, :line => line) }    #let!(:stop_areas) { Array.new(4) { create(:stop_area) } }    let!(:stop_points) { Array.new(4) { create(:stop_point, :route => route) } } +  let(:stop_area_referential) {stop_points.first.stop_area.stop_area_referential}    let!(:journey_pattern) { create(:journey_pattern, route: route) }    before { @user.update(organisation: referential.organisation) } @@ -88,6 +89,54 @@ describe "Routes", :type => :feature do            expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_journey_pattern_path(referential, line, route, journey_pattern))          end        end + +      def click_on_stop_point_dropdown_btn(num) +        find(:xpath, "(//div[contains(@class, 'btn') and contains(@class, 'dropdown-toggle')])[#{num}]").click +      end + +      context 'user does not have permission to edit stop areas' do +        it 'does not show edit links for stop areas' do +          @user.update_attribute(:permissions, []) +           +          expect(page).not_to have_content(I18n.t('stop_points.actions.edit'), visible: false) +          stop_points.each_with_index do |sp, i| +            click_on_stop_point_dropdown_btn(i + 1) +            expect(page).not_to have_link(I18n.t('stop_points.actions.edit'), href: edit_stop_area_referential_stop_area_path(stop_area_referential, sp)) +          end +        end +      end + +      context 'user has permission to edit stop areas' do +        xit 'shows edit links for stop areas' do +          @user.update_attribute(:permissions, ["stop_areas.update"]) +          visit referential_line_route_path(referential, line, route) +           +          stop_points.each_with_index do |sp, i| +            click_on_stop_point_dropdown_btn(i + 1) +            expect(page).to have_link(I18n.t('stop_points.actions.edit'), href: edit_stop_area_referential_stop_area_path(stop_area_referential, sp)) +          end +        end +      end + +      context 'user does not have permission to destroy stop areas' do +        it 'does not show destroy links for stop areas' do +          @user.update_attribute(:permissions, []) +          stop_points.each_with_index do |sp, i| +            click_on_stop_point_dropdown_btn(i + 1) +            expect(page).not_to have_link(I18n.t('stop_points.actions.destroy'), href: stop_area_referential_stop_area_path(sp.referential, sp)) +          end +        end +      end + +      context 'user has permission to destroy journey patterns' do +        xit 'shows destroy links for journey patterns' do +          @user.update_attribute(:permissions, ["stop_areas.destroy"]) +          stop_points.each_with_index do |sp, i| +            stop_point_action_links_btn(i + 1).click +            expect(page).to have_link(I18n.t('stop_points.actions.destroy'), href: stop_area_referential_stop_area_path(sp.referential, sp)) +          end +        end +      end      end      describe 'referential line show' do | 
