diff options
| author | Robert | 2017-05-31 17:28:31 +0200 | 
|---|---|---|
| committer | Robert | 2017-05-31 17:28:31 +0200 | 
| commit | 53fee6c7b1614f75ea5a5691d03c17f3caa58ac1 (patch) | |
| tree | 678aac81d692746cfcc6cc0c7c23e8afef222c6c | |
| parent | 57771cd083c14cb915445bd8f2ca96b8c0035f2a (diff) | |
| download | chouette-core-53fee6c7b1614f75ea5a5691d03c17f3caa58ac1.tar.bz2 | |
hotfix
| -rw-r--r-- | app/views/referentials/show.html.slim | 2 | ||||
| -rw-r--r-- | spec/features/referentials_permissions_spec.rb | 140 | 
2 files changed, 141 insertions, 1 deletions
| diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim index cad076e2c..9c60c2768 100644 --- a/app/views/referentials/show.html.slim +++ b/app/views/referentials/show.html.slim @@ -81,4 +81,4 @@      .modal-footer        button.btn.btn-link type='button' data-dismiss='modal' Annuler        - unless policy(@referential).archived? -        = buttonf.button :submit, t('actions.clean_up') , class: 'btn btn-primary' +        = f.button :submit, t('actions.clean_up') , class: 'btn btn-primary' diff --git a/spec/features/referentials_permissions_spec.rb b/spec/features/referentials_permissions_spec.rb new file mode 100644 index 000000000..3c2258a3a --- /dev/null +++ b/spec/features/referentials_permissions_spec.rb @@ -0,0 +1,140 @@ +# -*- coding: utf-8 -*- +require 'spec_helper' + +describe "Referentials", :type => :feature do +  login_user + +  let(:referential) { Referential.first } + +  describe "index" do + +    # FIXME #823 +    # it "should support no referential" do +    #   visit referentials_path +    #   expect(page).to have_content("Jeux de Données") +    # end + +    context "when several referentials exist" do + +      def retrieve_referential_by_slug( slug) +        @user.organisation.referentials.find_by_slug(slug) || +          create(:referential, :slug => slug, :name => slug, :organisation => @user.organisation) +      end + +      let!(:referentials) { [ retrieve_referential_by_slug("aa"), +                              retrieve_referential_by_slug("bb")] } + +      # FIXME #823 +      # it "should show n referentials" do +      #   visit referentials_path +      #   expect(page).to have_content(referentials.first.name) +      #   expect(page).to have_content(referentials.last.name) +      # end + +    end + +  end + +  describe "show" do +    before(:each) { visit referential_path(referential) } + +    it "displays referential" do +      expect(page).to have_content(referential.name) +    end + +    context 'archived referential' do +      it 'link to edit referetnial is not displayed' do +        referential.archive! +        visit referential_path(referential) +        expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential)) +      end +    end + +    context 'unarchived referential' do +      it 'link to edit referetnial is displayed' do +        expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential)) +      end +    end + +    context 'user has the permission to create referentials' do +      it 'shows the clone link for referetnial' do +        expect(page).to have_link(I18n.t('actions.clone'), href: new_referential_path(from: referential.id)) +      end +    end + +    context 'user does not have the permission to create referentials' do +      it 'does not show the clone link for referetnial' do +        @user.update_attribute(:permissions, []) +        visit referential_path(referential) +        expect(page).not_to have_link(I18n.t('actions.clone'), href: new_referential_path(from: referential.id)) +      end +    end + +    context 'user has the permission to edit referentials' do +      it 'shows the link to edit the referential' do +        expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential)) +      end + +      it 'shows the link to archive the referential' do +        expect(page).to have_link(I18n.t('actions.archive'), href: archive_referential_path(referential)) +      end +    end + +    context 'user does not have the permission to edit referentials' do +      before(:each) do +        @user.update_attribute(:permissions, []) +        visit referential_path(referential) +      end + +      it 'does not show the link to edit the referential' do +        expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential)) +      end + +      it 'does not show the link to archive the referential' do +        expect(page).not_to have_link(I18n.t('actions.archive'), href: archive_referential_path(referential)) +      end +    end + +    context 'user has the permission to destroy referentials' do +      it 'shows the link to destroy the referential' do +        expect(page).to have_link(I18n.t('actions.destroy'), href: referential_path(referential)) +      end +    end + +    context 'user does not have the permission to destroy referentials' do +      it 'does not show the destroy link for referetnial' do +        @user.update_attribute(:permissions, []) +        visit referential_path(referential) +        expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_path(referential)) +      end +    end +  end + +  describe "create" do + +    it "should" do +      visit new_referential_path +      fill_in "Nom", :with => "Test" +      fill_in "Code", :with => "test" +      fill_in "Point haut/droite de l'emprise par défaut", :with => "0.0, 0.0" +      fill_in "Point bas/gauche de l'emprise par défaut", :with => "1.0, 1.0" +      click_button "Valider" + +      expect(Referential.where(:name => "Test")).not_to be_nil +      # CREATE SCHEMA +    end + +  end + +  describe "destroy" do +    let(:referential) {  create(:referential, :organisation => @user.organisation) } + +    it "should remove referential" do +      visit referential_path(referential) +      #click_link "Supprimer" +      #expect(Referential.where(:slug => referential.slug)).to be_blank +    end + +  end + +end | 
