diff options
| author | Vlatka Pavisic | 2017-01-18 11:05:51 +0100 | 
|---|---|---|
| committer | Vlatka Pavisic | 2017-01-18 11:05:51 +0100 | 
| commit | 242455e1b6191453f7af98cd29390651ab871e51 (patch) | |
| tree | 0e75e9c3e1c629c819dbab91ae0f6acd4a859c1a /spec/features/journey_pattern_spec.rb | |
| parent | 307f808e2c812bccccd1c6246ca6b8583be4ef40 (diff) | |
| download | chouette-core-242455e1b6191453f7af98cd29390651ab871e51.tar.bz2 | |
Refs #2426 : JourneyPattern User permissions
Diffstat (limited to 'spec/features/journey_pattern_spec.rb')
| -rw-r--r-- | spec/features/journey_pattern_spec.rb | 47 | 
1 files changed, 47 insertions, 0 deletions
| diff --git a/spec/features/journey_pattern_spec.rb b/spec/features/journey_pattern_spec.rb index 1dbd2752d..380241099 100644 --- a/spec/features/journey_pattern_spec.rb +++ b/spec/features/journey_pattern_spec.rb @@ -8,6 +8,53 @@ describe "JourneyPatterns", :type => :feature do    let!(:route) { create(:route, :line => line) }    let!(:journey_pattern) { create(:journey_pattern, :route => route) } +  describe 'show' do +    context 'user has permission to create journey patterns' do +      it 'shows the create link for journey pattern' do +        visit referential_line_route_journey_pattern_path(referential, line, route, journey_pattern) +        expect(page).to have_content(I18n.t('journey_patterns.actions.new')) +      end +    end + +    context 'user does not have permission to create journey patterns' do +      it 'does not show the create link for journey pattern' do +        @user.update_attribute(:permissions, ['journey_patterns.edit', 'journey_patterns.destroy']) +        visit referential_line_route_journey_pattern_path(referential, line, route, journey_pattern) +        expect(page).not_to have_content(I18n.t('journey_patterns.actions.new')) +      end +    end + +    context 'user has permission to edit journey patterns' do +      it 'shows the edit link for journey pattern' do +        visit referential_line_route_journey_pattern_path(referential, line, route, journey_pattern) +        expect(page).to have_content(I18n.t('journey_patterns.actions.edit')) +      end +    end + +    context 'user does not have permission to edit journey patterns' do +      it 'does not show the edit link for journey pattern' do +        @user.update_attribute(:permissions, ['journey_patterns.create', 'journey_patterns.destroy']) +        visit referential_line_route_journey_pattern_path(referential, line, route, journey_pattern) +        expect(page).not_to have_content(I18n.t('journey_patterns.actions.edit')) +      end +    end + +    context 'user has permission to destroy journey patterns' do +      it 'shows the destroy link for journey pattern' do +        visit referential_line_route_journey_pattern_path(referential, line, route, journey_pattern) +        expect(page).to have_content(I18n.t('journey_patterns.actions.destroy')) +      end +    end + +    context 'user does not have permission to edit journey patterns' do +      it 'does not show the destroy link for journey pattern' do +        @user.update_attribute(:permissions, ['journey_patterns.create', 'journey_patterns.edit']) +        visit referential_line_route_journey_pattern_path(referential, line, route, journey_pattern) +        expect(page).not_to have_content(I18n.t('journey_patterns.actions.destroy')) +      end +    end +  end +    # describe "from routes page to a journey_pattern page" do    #   it "display route's journey_patterns" do    #     visit referential_line_route_path(referential,line,route) | 
