diff --git a/spec/support/integration_spec_helper.rb b/spec/support/integration_spec_helper.rb
new file mode 100644
index 000000000..958aab9d5
--- /dev/null
+++ b/spec/support/integration_spec_helper.rb
@@ -0,0 +1,17 @@
+module IntegrationSpecHelper
+ extend ActiveSupport::Concern
+
+ included do
+ def self.with_permission permission, &block
+ context "with permission #{permission}" do
+ let(:permissions){ [permission] }
+ context('', &block) if block_given?
+ end
+ end
+ end
+end
+
+
+RSpec.configure do |config|
+ config.include IntegrationSpecHelper, type: :view
+end
diff --git a/spec/support/pundit/pundit_view_policy.rb b/spec/support/pundit/pundit_view_policy.rb
index b8434cac0..02a78a4e0 100644
--- a/spec/support/pundit/pundit_view_policy.rb
+++ b/spec/support/pundit/pundit_view_policy.rb
@@ -3,14 +3,16 @@ module Pundit
extend ActiveSupport::Concern
included do
+
+ let(:permissions){ nil }
+ let(:current_referential){ build_stubbed :referential }
+ let(:current_user){ build_stubbed :user, permissions: permissions }
+ let(:pundit_user){ UserContext.new(current_user, referential: current_referential) }
before do
- controller.singleton_class.class_eval do
- def policy(instance)
- Class.new do
- def method_missing(*args, &block); true; end
- end.new
- end
- helper_method :policy
+ allow(view).to receive(:pundit_user) { pundit_user }
+
+ allow(view).to receive(:policy) do |instance|
+ ::Pundit.policy pundit_user, instance
end
end
end
diff --git a/spec/views/stop_areas/index.html.erb_spec.rb b/spec/views/stop_areas/index.html.erb_spec.rb
index 2dfae1bfd..a354586d2 100644
--- a/spec/views/stop_areas/index.html.erb_spec.rb
+++ b/spec/views/stop_areas/index.html.erb_spec.rb
@@ -1,25 +1,77 @@
require 'spec_helper'
describe "/stop_areas/index", :type => :view do
-
let!(:stop_area_referential) { assign :stop_area_referential, create(:stop_area_referential) }
- let!(:stop_areas) { assign :stop_areas, Array.new(2) { create(:stop_area, stop_area_referential: stop_area_referential) }.paginate }
+ let!(:stop_areas) do
+ 2.times { create(:stop_area, stop_area_referential: stop_area_referential) }
+ assign :stop_areas, ModelDecorator.decorate( Chouette::StopArea.page(1), with: StopAreaDecorator )
+ end
let!(:q) { assign :q, Ransack::Search.new(Chouette::StopArea) }
before :each do
allow(view).to receive(:link_with_search).and_return("#")
+ allow(view).to receive(:collection).and_return(stop_areas)
+ allow(view).to receive(:current_referential).and_return(stop_area_referential)
+ controller.request.path_parameters[:stop_area_referential_id] = stop_area_referential.id
+ render
+ end
+
+ it "should render a row for each group" do
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id}", count: 1)
+ end
+ end
+
+ it "should render a show link for each group" do
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", count: 1)
+ end
+ end
+
+ it "should render no other link for each group" do
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: 1)
+ end
end
- # it "should render a show link for each group" do
- # render
- # stop_areas.each do |stop_area|
- # expect(rendered).to have_selector(".stop_area a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", :text => stop_area.name)
- # 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_stop_area_referential_stop_area_path(stop_area_referential)}']")
- # end
+ with_permission "stop_areas.create" do
+ it "should render a show link for each group" do
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", count: 1)
+ end
+ end
+
+ it "should render a create link for each group" do
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.new_stop_area_referential_stop_area_path(stop_area_referential)}']", count: 1)
+ end
+ end
+
+ it "should render no other link for each group" do
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: 2)
+ end
+ end
+ end
+
+ with_permission "stop_areas.update" do
+ it "should render a show link for each group" do
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", count: 1)
+ end
+ end
+
+ it "should render a edit link for each group" do
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.edit_stop_area_referential_stop_area_path(stop_area_referential, stop_area.id)}']", count: 1)
+ end
+ end
+
+ it "should render no other link for each group" do
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: 2)
+ end
+ end
+ end
end
--
cgit v1.2.3
From 357563bbf408aa2000097ee200dfbfba1f677121 Mon Sep 17 00:00:00 2001
From: Zog
Date: Fri, 15 Dec 2017 11:27:14 +0100
Subject: - 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
---
spec/support/pundit/pundit_view_policy.rb | 5 +++--
spec/views/connection_links/index.html.erb_spec.rb | 8 +++++---
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
-
--
cgit v1.2.3
From 2091a1ababa68810f42257fb392692f80b3bd78f Mon Sep 17 00:00:00 2001
From: Zog
Date: Fri, 15 Dec 2017 14:52:33 +0100
Subject: Refactor stopareas index specs
---
spec/views/stop_areas/index.html.erb_spec.rb | 78 ++++++++++------------------
1 file changed, 27 insertions(+), 51 deletions(-)
diff --git a/spec/views/stop_areas/index.html.erb_spec.rb b/spec/views/stop_areas/index.html.erb_spec.rb
index a354586d2..e0c50685c 100644
--- a/spec/views/stop_areas/index.html.erb_spec.rb
+++ b/spec/views/stop_areas/index.html.erb_spec.rb
@@ -1,6 +1,25 @@
require 'spec_helper'
+RSpec::Matchers.define :have_link_for_each_stop_area do |stop_areas, name, href|
+ match do |actual|
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{href.call(stop_area)}']", count: 1)
+ end
+ end
+ description { "have #{name} link for each stop area" }
+end
+
+RSpec::Matchers.define :have_the_right_number_of_links do |stop_areas, count|
+ match do |actual|
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: count)
+ end
+ end
+ description { "have #{count} links for each stop area" }
+end
+
describe "/stop_areas/index", :type => :view do
+
let!(:stop_area_referential) { assign :stop_area_referential, create(:stop_area_referential) }
let!(:stop_areas) do
2.times { create(:stop_area, stop_area_referential: stop_area_referential) }
@@ -16,62 +35,19 @@ describe "/stop_areas/index", :type => :view do
render
end
- it "should render a row for each group" do
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id}", count: 1)
- end
- end
-
- it "should render a show link for each group" do
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", count: 1)
- end
- end
-
- it "should render no other link for each group" do
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: 1)
- end
- end
+ it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
+ it { should have_the_right_number_of_links(stop_areas, 1) }
with_permission "stop_areas.create" do
- it "should render a show link for each group" do
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", count: 1)
- end
- end
-
- it "should render a create link for each group" do
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.new_stop_area_referential_stop_area_path(stop_area_referential)}']", count: 1)
- end
- end
-
- it "should render no other link for each group" do
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: 2)
- end
- end
+ it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
+ it { should have_link_for_each_stop_area(stop_areas, "create", -> (stop_area){ view.new_stop_area_referential_stop_area_path(stop_area_referential) }) }
+ it { should have_the_right_number_of_links(stop_areas, 2) }
end
with_permission "stop_areas.update" do
- it "should render a show link for each group" do
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", count: 1)
- end
- end
-
- it "should render a edit link for each group" do
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.edit_stop_area_referential_stop_area_path(stop_area_referential, stop_area.id)}']", count: 1)
- end
- end
-
- it "should render no other link for each group" do
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: 2)
- end
- end
+ it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
+ it { should have_link_for_each_stop_area(stop_areas, "edit", -> (stop_area){ view.edit_stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
+ it { should have_the_right_number_of_links(stop_areas, 2) }
end
end
--
cgit v1.2.3
From 548fe7f13d698fe9a6620ef60fc239f28347af79 Mon Sep 17 00:00:00 2001
From: Zog
Date: Mon, 18 Dec 2017 09:25:10 +0100
Subject: Refs #5287; CR 1
- Get rid of ActiveSupport::Concern in the spec helpers
- Rename misnamed spec files
---
spec/support/integration_spec_helper.rb | 15 ++----
spec/support/pundit/pundit_view_policy.rb | 17 +++----
spec/views/connection_links/show.html.erb_spec.rb | 32 -------------
spec/views/connection_links/show.html.slim_spec.rb | 32 +++++++++++++
spec/views/stop_areas/index.html.erb_spec.rb | 53 ----------------------
spec/views/stop_areas/index.html.slim_spec.rb | 53 ++++++++++++++++++++++
6 files changed, 97 insertions(+), 105 deletions(-)
delete mode 100644 spec/views/connection_links/show.html.erb_spec.rb
create mode 100644 spec/views/connection_links/show.html.slim_spec.rb
delete mode 100644 spec/views/stop_areas/index.html.erb_spec.rb
create mode 100644 spec/views/stop_areas/index.html.slim_spec.rb
diff --git a/spec/support/integration_spec_helper.rb b/spec/support/integration_spec_helper.rb
index 958aab9d5..182cadf24 100644
--- a/spec/support/integration_spec_helper.rb
+++ b/spec/support/integration_spec_helper.rb
@@ -1,17 +1,12 @@
module IntegrationSpecHelper
- extend ActiveSupport::Concern
-
- included do
- def self.with_permission permission, &block
- context "with permission #{permission}" do
- let(:permissions){ [permission] }
- context('', &block) if block_given?
- end
+ def with_permission permission, &block
+ context "with permission #{permission}" do
+ let(:permissions){ [permission] }
+ context('', &block) if block_given?
end
end
end
-
RSpec.configure do |config|
- config.include IntegrationSpecHelper, type: :view
+ config.extend IntegrationSpecHelper, type: :view
end
diff --git a/spec/support/pundit/pundit_view_policy.rb b/spec/support/pundit/pundit_view_policy.rb
index 6a663a471..91be0624c 100644
--- a/spec/support/pundit/pundit_view_policy.rb
+++ b/spec/support/pundit/pundit_view_policy.rb
@@ -1,15 +1,12 @@
module Pundit
module PunditViewPolicy
- extend ActiveSupport::Concern
-
- included do
-
- let(:permissions){ nil }
- 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
+ def self.included into
+ into.let(:permissions){ nil }
+ into.let(:organisation){ referential.try(:organisation) }
+ into.let(:current_referential){ referential || build_stubbed(:referential) }
+ into.let(:current_user){ build_stubbed :user, permissions: permissions, organisation: organisation }
+ into.let(:pundit_user){ UserContext.new(current_user, referential: current_referential) }
+ into.before do
allow(view).to receive(:pundit_user) { pundit_user }
allow(view).to receive(:policy) do |instance|
diff --git a/spec/views/connection_links/show.html.erb_spec.rb b/spec/views/connection_links/show.html.erb_spec.rb
deleted file mode 100644
index afe94fc6c..000000000
--- a/spec/views/connection_links/show.html.erb_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-describe "/connection_links/show", :type => :view do
-
- assign_referential
- let!(:connection_link) { assign(:connection_link, create(:connection_link)) }
- let!(:map) { assign(:map, double(:to_html => ''.html_safe)) }
-
- before do
- allow(view).to receive_messages(current_organisation: referential.organisation)
- end
-
- it "should render h2 with the connection_link name" do
- render
- expect(rendered).to have_selector("h2", :text => Regexp.new(connection_link.name))
- end
-
- 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
-
- 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
diff --git a/spec/views/connection_links/show.html.slim_spec.rb b/spec/views/connection_links/show.html.slim_spec.rb
new file mode 100644
index 000000000..afe94fc6c
--- /dev/null
+++ b/spec/views/connection_links/show.html.slim_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper'
+
+describe "/connection_links/show", :type => :view do
+
+ assign_referential
+ let!(:connection_link) { assign(:connection_link, create(:connection_link)) }
+ let!(:map) { assign(:map, double(:to_html => ''.html_safe)) }
+
+ before do
+ allow(view).to receive_messages(current_organisation: referential.organisation)
+ end
+
+ it "should render h2 with the connection_link name" do
+ render
+ expect(rendered).to have_selector("h2", :text => Regexp.new(connection_link.name))
+ end
+
+ 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
+
+ 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
diff --git a/spec/views/stop_areas/index.html.erb_spec.rb b/spec/views/stop_areas/index.html.erb_spec.rb
deleted file mode 100644
index e0c50685c..000000000
--- a/spec/views/stop_areas/index.html.erb_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'spec_helper'
-
-RSpec::Matchers.define :have_link_for_each_stop_area do |stop_areas, name, href|
- match do |actual|
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{href.call(stop_area)}']", count: 1)
- end
- end
- description { "have #{name} link for each stop area" }
-end
-
-RSpec::Matchers.define :have_the_right_number_of_links do |stop_areas, count|
- match do |actual|
- stop_areas.each do |stop_area|
- expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: count)
- end
- end
- description { "have #{count} links for each stop area" }
-end
-
-describe "/stop_areas/index", :type => :view do
-
- let!(:stop_area_referential) { assign :stop_area_referential, create(:stop_area_referential) }
- let!(:stop_areas) do
- 2.times { create(:stop_area, stop_area_referential: stop_area_referential) }
- assign :stop_areas, ModelDecorator.decorate( Chouette::StopArea.page(1), with: StopAreaDecorator )
- end
- let!(:q) { assign :q, Ransack::Search.new(Chouette::StopArea) }
-
- before :each do
- allow(view).to receive(:link_with_search).and_return("#")
- allow(view).to receive(:collection).and_return(stop_areas)
- allow(view).to receive(:current_referential).and_return(stop_area_referential)
- controller.request.path_parameters[:stop_area_referential_id] = stop_area_referential.id
- render
- end
-
- it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
- it { should have_the_right_number_of_links(stop_areas, 1) }
-
- with_permission "stop_areas.create" do
- it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
- it { should have_link_for_each_stop_area(stop_areas, "create", -> (stop_area){ view.new_stop_area_referential_stop_area_path(stop_area_referential) }) }
- it { should have_the_right_number_of_links(stop_areas, 2) }
- end
-
- with_permission "stop_areas.update" do
- it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
- it { should have_link_for_each_stop_area(stop_areas, "edit", -> (stop_area){ view.edit_stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
- it { should have_the_right_number_of_links(stop_areas, 2) }
- end
-
-end
diff --git a/spec/views/stop_areas/index.html.slim_spec.rb b/spec/views/stop_areas/index.html.slim_spec.rb
new file mode 100644
index 000000000..e0c50685c
--- /dev/null
+++ b/spec/views/stop_areas/index.html.slim_spec.rb
@@ -0,0 +1,53 @@
+require 'spec_helper'
+
+RSpec::Matchers.define :have_link_for_each_stop_area do |stop_areas, name, href|
+ match do |actual|
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{href.call(stop_area)}']", count: 1)
+ end
+ end
+ description { "have #{name} link for each stop area" }
+end
+
+RSpec::Matchers.define :have_the_right_number_of_links do |stop_areas, count|
+ match do |actual|
+ stop_areas.each do |stop_area|
+ expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: count)
+ end
+ end
+ description { "have #{count} links for each stop area" }
+end
+
+describe "/stop_areas/index", :type => :view do
+
+ let!(:stop_area_referential) { assign :stop_area_referential, create(:stop_area_referential) }
+ let!(:stop_areas) do
+ 2.times { create(:stop_area, stop_area_referential: stop_area_referential) }
+ assign :stop_areas, ModelDecorator.decorate( Chouette::StopArea.page(1), with: StopAreaDecorator )
+ end
+ let!(:q) { assign :q, Ransack::Search.new(Chouette::StopArea) }
+
+ before :each do
+ allow(view).to receive(:link_with_search).and_return("#")
+ allow(view).to receive(:collection).and_return(stop_areas)
+ allow(view).to receive(:current_referential).and_return(stop_area_referential)
+ controller.request.path_parameters[:stop_area_referential_id] = stop_area_referential.id
+ render
+ end
+
+ it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
+ it { should have_the_right_number_of_links(stop_areas, 1) }
+
+ with_permission "stop_areas.create" do
+ it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
+ it { should have_link_for_each_stop_area(stop_areas, "create", -> (stop_area){ view.new_stop_area_referential_stop_area_path(stop_area_referential) }) }
+ it { should have_the_right_number_of_links(stop_areas, 2) }
+ end
+
+ with_permission "stop_areas.update" do
+ it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
+ it { should have_link_for_each_stop_area(stop_areas, "edit", -> (stop_area){ view.edit_stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
+ it { should have_the_right_number_of_links(stop_areas, 2) }
+ end
+
+end
--
cgit v1.2.3
From 129f10e701a72690091cd4e5af1c88e55194e12d Mon Sep 17 00:00:00 2001
From: Alban Peignier
Date: Mon, 18 Dec 2017 19:18:31 +0100
Subject: Fix link use in StopArea name into stop_areas#index. Refs #5287
---
app/views/stop_areas/index.html.slim | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim
index 99b399f5c..dbf3b848d 100644
--- a/app/views/stop_areas/index.html.slim
+++ b/app/views/stop_areas/index.html.slim
@@ -24,7 +24,7 @@
key: :name, \
attribute: 'name', \
link_to: lambda do |stop_area| \
- referential_stop_area_path( \
+ stop_area_referential_stop_area_path( \
@stop_area_referential, \
stop_area \
) \
--
cgit v1.2.3
From 4983eca8f4be6acf00589d4d34e7dc17377bb070 Mon Sep 17 00:00:00 2001
From: Zog
Date: Tue, 19 Dec 2017 13:09:47 +0100
Subject: Refs #5287@0.5h; Use I18n in dashboard
For calendars panel, instead of hardcoded string
---
app/assets/stylesheets/components/_panels.sass | 1 +
app/views/dashboards/_dashboard.html.slim | 2 +-
config/locales/calendars.en.yml | 5 +++--
config/locales/calendars.fr.yml | 5 +++--
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/app/assets/stylesheets/components/_panels.sass b/app/assets/stylesheets/components/_panels.sass
index e9f615081..ab25d8184 100644
--- a/app/assets/stylesheets/components/_panels.sass
+++ b/app/assets/stylesheets/components/_panels.sass
@@ -34,6 +34,7 @@
a
text-decoration: none
color: $blue
+ text-transform: capitalize
&:hover, &:focus
color: $darkblue
diff --git a/app/views/dashboards/_dashboard.html.slim b/app/views/dashboards/_dashboard.html.slim
index e5aa5093a..7d547bf4c 100644
--- a/app/views/dashboards/_dashboard.html.slim
+++ b/app/views/dashboards/_dashboard.html.slim
@@ -22,7 +22,7 @@
.panel.panel-default
.panel-heading
h3.panel-title.with_actions
- = link_to "Modèles de calendrier", calendars_path
+ = link_to I18n.t("activerecord.models.calendar", count: @dashboard.current_organisation.calendars.size), calendars_path
div
= link_to '', calendars_path, class: ' fa fa-chevron-right pull-right'
- if @dashboard.current_organisation.calendars.present?
diff --git a/config/locales/calendars.en.yml b/config/locales/calendars.en.yml
index 0076e5207..d3cc57677 100644
--- a/config/locales/calendars.en.yml
+++ b/config/locales/calendars.en.yml
@@ -56,8 +56,9 @@ en:
end: End
activerecord:
models:
- one: calendar
- other: calendars
+ calendar:
+ one: calendar
+ other: calendars
attributes:
calendar:
name: Name
diff --git a/config/locales/calendars.fr.yml b/config/locales/calendars.fr.yml
index fddb47d64..fc895bf89 100644
--- a/config/locales/calendars.fr.yml
+++ b/config/locales/calendars.fr.yml
@@ -56,8 +56,9 @@ fr:
end: Fin
activerecord:
models:
- one: "calendrier"
- other: "calendriers"
+ calendar:
+ one: "calendrier"
+ other: "calendriers"
attributes:
calendar:
name: Nom
--
cgit v1.2.3
From 4b9eebda5bb81a214c87351c01c720c0cb0cf2e8 Mon Sep 17 00:00:00 2001
From: Zog
Date: Tue, 19 Dec 2017 16:10:15 +0100
Subject: Refs #5287; Uniformize actions
---
app/decorators/stop_area_decorator.rb | 9 ---------
config/locales/stop_areas.en.yml | 2 +-
config/locales/stop_areas.fr.yml | 2 +-
spec/views/stop_areas/index.html.slim_spec.rb | 4 ++--
4 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/app/decorators/stop_area_decorator.rb b/app/decorators/stop_area_decorator.rb
index 4e777292d..8b2ebf490 100644
--- a/app/decorators/stop_area_decorator.rb
+++ b/app/decorators/stop_area_decorator.rb
@@ -7,15 +7,6 @@ class StopAreaDecorator < Draper::Decorator
links = []
stop_area ||= object
- if h.policy(Chouette::StopArea).new?
- links << Link.new(
- content: h.t('stop_areas.actions.new'),
- href: h.new_stop_area_referential_stop_area_path(
- stop_area.stop_area_referential
- )
- )
- end
-
if h.policy(stop_area).update?
links << Link.new(
content: h.t('stop_areas.actions.edit'),
diff --git a/config/locales/stop_areas.en.yml b/config/locales/stop_areas.en.yml
index 324294892..54a5ebae5 100644
--- a/config/locales/stop_areas.en.yml
+++ b/config/locales/stop_areas.en.yml
@@ -15,7 +15,7 @@ en:
actions:
new: "Add a new stop"
edit: "Edit this stop"
- destroy: "Remove this stop"
+ destroy: "Remove"
deleted_at: "Activated"
destroy_confirm: "Are you sure you want destroy this stop and all of his children ?"
select_parent: "Create or modify the relation child -> parent"
diff --git a/config/locales/stop_areas.fr.yml b/config/locales/stop_areas.fr.yml
index bf4dd832f..f96a2e564 100644
--- a/config/locales/stop_areas.fr.yml
+++ b/config/locales/stop_areas.fr.yml
@@ -15,7 +15,7 @@ fr:
actions:
new: "Ajouter un arrêt"
edit: "Editer cet arrêt"
- destroy: "Supprimer cet arrêt"
+ destroy: "Supprimer"
deleted_at: "Activé"
destroy_confirm: "Etes vous sûr de supprimer cet arrêt ainsi que tous ses fils?"
select_parent: "Créer ou éditer la relation enfant -> parent"
diff --git a/spec/views/stop_areas/index.html.slim_spec.rb b/spec/views/stop_areas/index.html.slim_spec.rb
index e0c50685c..64c958879 100644
--- a/spec/views/stop_areas/index.html.slim_spec.rb
+++ b/spec/views/stop_areas/index.html.slim_spec.rb
@@ -40,8 +40,8 @@ describe "/stop_areas/index", :type => :view do
with_permission "stop_areas.create" do
it { should have_link_for_each_stop_area(stop_areas, "show", -> (stop_area){ view.stop_area_referential_stop_area_path(stop_area_referential, stop_area) }) }
- it { should have_link_for_each_stop_area(stop_areas, "create", -> (stop_area){ view.new_stop_area_referential_stop_area_path(stop_area_referential) }) }
- it { should have_the_right_number_of_links(stop_areas, 2) }
+ it { should_not have_link_for_each_stop_area(stop_areas, "create", -> (stop_area){ view.new_stop_area_referential_stop_area_path(stop_area_referential) }) }
+ it { should have_the_right_number_of_links(stop_areas, 1) }
end
with_permission "stop_areas.update" do
--
cgit v1.2.3