diff options
| author | Zog | 2017-12-15 11:27:14 +0100 |
|---|---|---|
| committer | Zog | 2017-12-19 14:40:38 +0100 |
| commit | 357563bbf408aa2000097ee200dfbfba1f677121 (patch) | |
| tree | 295d5a413c3b5e0d592fd1d700f713746134120f | |
| parent | 676f45e8fd85c1422345d4d27ba2385e4bd536fe (diff) | |
| download | chouette-core-357563bbf408aa2000097ee200dfbfba1f677121.tar.bz2 | |
- Fix specs on connections_links/index
- Fix specs on connections_links/show
- Update pundit view specs helper to use the current referential when it
has already been defined
| -rw-r--r-- | spec/support/pundit/pundit_view_policy.rb | 5 | ||||
| -rw-r--r-- | spec/views/connection_links/index.html.erb_spec.rb | 8 | ||||
| -rw-r--r-- | spec/views/connection_links/show.html.erb_spec.rb | 23 |
3 files changed, 18 insertions, 18 deletions
diff --git a/spec/support/pundit/pundit_view_policy.rb b/spec/support/pundit/pundit_view_policy.rb index 02a78a4e0..6a663a471 100644 --- a/spec/support/pundit/pundit_view_policy.rb +++ b/spec/support/pundit/pundit_view_policy.rb @@ -5,8 +5,9 @@ module Pundit included do let(:permissions){ nil } - let(:current_referential){ build_stubbed :referential } - let(:current_user){ build_stubbed :user, permissions: permissions } + let(:organisation){ referential.try(:organisation) } + let(:current_referential){ referential || build_stubbed(:referential) } + let(:current_user){ build_stubbed :user, permissions: permissions, organisation: organisation } let(:pundit_user){ UserContext.new(current_user, referential: current_referential) } before do allow(view).to receive(:pundit_user) { pundit_user } diff --git a/spec/views/connection_links/index.html.erb_spec.rb b/spec/views/connection_links/index.html.erb_spec.rb index a01380094..1f133e31e 100644 --- a/spec/views/connection_links/index.html.erb_spec.rb +++ b/spec/views/connection_links/index.html.erb_spec.rb @@ -17,9 +17,11 @@ describe "/connection_links/index", :type => :view do end end - it "should render a link to create a new group" do - render - expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{new_referential_connection_link_path(referential)}']") + with_permission "connection_links.create" do + it "should render a link to create a new group" do + render + expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{new_referential_connection_link_path(referential)}']") + end end end diff --git a/spec/views/connection_links/show.html.erb_spec.rb b/spec/views/connection_links/show.html.erb_spec.rb index c04a4f3f1..afe94fc6c 100644 --- a/spec/views/connection_links/show.html.erb_spec.rb +++ b/spec/views/connection_links/show.html.erb_spec.rb @@ -15,21 +15,18 @@ describe "/connection_links/show", :type => :view do expect(rendered).to have_selector("h2", :text => Regexp.new(connection_link.name)) end -# it "should display a map with class 'connection_link'" do -# pending ": map not yet implemented" -# render -# expect(rendered).to have_selector("#map", :class => 'connection_link') -# end - - it "should render a link to edit the connection_link" do - render - expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.edit_referential_connection_link_path(referential, connection_link)}']") + with_permission "connection_links.update" do + it "should render a link to edit the connection_link" do + render + expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.edit_referential_connection_link_path(referential, connection_link)}']") + end end - it "should render a link to remove the connection_link" do - render - expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.referential_connection_link_path(referential, connection_link)}'][class='remove']") + with_permission "connection_links.destroy" do + it "should render a link to remove the connection_link" do + render + expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.referential_connection_link_path(referential, connection_link)}'][class='remove']") + end end end - |
