aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/assets/stylesheets/components/_panels.sass1
-rw-r--r--app/helpers/table_builder_helper.rb10
-rw-r--r--app/views/dashboards/_dashboard.html.slim2
-rw-r--r--app/views/stop_areas/index.html.slim4
-rw-r--r--config/locales/calendars.en.yml5
-rw-r--r--config/locales/calendars.fr.yml5
-rw-r--r--spec/helpers/table_builder_helper_spec.rb6
-rw-r--r--spec/support/pundit/pundit_view_policy.rb20
-rw-r--r--spec/views/connection_links/index.html.erb_spec.rb8
-rw-r--r--spec/views/connection_links/show.html.erb_spec.rb35
-rw-r--r--spec/views/stop_areas/index.html.erb_spec.rb25
11 files changed, 85 insertions, 36 deletions
diff --git a/app/assets/stylesheets/components/_panels.sass b/app/assets/stylesheets/components/_panels.sass
index ab25d8184..e9f615081 100644
--- a/app/assets/stylesheets/components/_panels.sass
+++ b/app/assets/stylesheets/components/_panels.sass
@@ -34,7 +34,6 @@
a
text-decoration: none
color: $blue
- text-transform: capitalize
&:hover, &:focus
color: $darkblue
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 64bec6bae..37f01ce0d 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -188,16 +188,10 @@ module TableBuilderHelper
end
def tbody(collection, columns, selectable, links, overhead)
- if collection.respond_to?(:model)
- model_name = collection.model.name.split("::").last
- else
- model_name = "item"
- end
-
content_tag :tbody do
collection.map do |item|
- klass = "#{model_name.parameterize}-#{item.id}"
- content_tag :tr, class: klass do
+
+ content_tag :tr do
bcont = []
if selectable
diff --git a/app/views/dashboards/_dashboard.html.slim b/app/views/dashboards/_dashboard.html.slim
index 7d547bf4c..e5aa5093a 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 I18n.t("activerecord.models.calendar", count: @dashboard.current_organisation.calendars.size), calendars_path
+ = link_to "Modèles de calendrier", calendars_path
div
= link_to '', calendars_path, class: ' fa fa-chevron-right pull-right'
- if @dashboard.current_organisation.calendars.present?
diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim
index dbf3b848d..c4d880081 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| \
- stop_area_referential_stop_area_path( \
+ referential_stop_area_path( \
@stop_area_referential, \
stop_area \
) \
@@ -51,7 +51,7 @@
attribute: Proc.new { |s| (s.area_type.nil? ? '-' : t("enumerize.stop_area.area_type.#{s.try(:area_type)}")) } \
), \
],
- links: [:show],
+ links: [:show, :edit, :delete],
cls: 'table has-filter has-search'
= new_pagination @stop_areas, 'pull-right'
diff --git a/config/locales/calendars.en.yml b/config/locales/calendars.en.yml
index d3cc57677..0076e5207 100644
--- a/config/locales/calendars.en.yml
+++ b/config/locales/calendars.en.yml
@@ -56,9 +56,8 @@ en:
end: End
activerecord:
models:
- calendar:
- one: calendar
- other: calendars
+ one: calendar
+ other: calendars
attributes:
calendar:
name: Name
diff --git a/config/locales/calendars.fr.yml b/config/locales/calendars.fr.yml
index fc895bf89..fddb47d64 100644
--- a/config/locales/calendars.fr.yml
+++ b/config/locales/calendars.fr.yml
@@ -56,9 +56,8 @@ fr:
end: Fin
activerecord:
models:
- calendar:
- one: "calendrier"
- other: "calendriers"
+ one: "calendrier"
+ other: "calendriers"
attributes:
calendar:
name: Nom
diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb
index 3b3504c60..3b0a18379 100644
--- a/spec/helpers/table_builder_helper_spec.rb
+++ b/spec/helpers/table_builder_helper_spec.rb
@@ -59,7 +59,7 @@ describe TableBuilderHelper, type: :helper do
</tr>
</thead>
<tbody>
- <tr class="referential-#{referential.id}">
+ <tr>
<td>
<div class="checkbox"><input type="checkbox" name="#{referential.id}" id="#{referential.id}" value="#{referential.id}" /><label for="#{referential.id}"></label></div>
</td>
@@ -213,7 +213,7 @@ describe TableBuilderHelper, type: :helper do
</tr>
</thead>
<tbody>
- <tr class="company-#{company.id}">
+ <tr>
<td>#{company.get_objectid.local_id}</td>
<td title="Voir"><a href="/referentials/#{referential.id}/companies/#{company.id}">#{company.name}</a></td>
<td></td>
@@ -326,7 +326,7 @@ describe TableBuilderHelper, type: :helper do
</tr>
</thead>
<tbody>
- <tr class="company-#{company.id}">
+ <tr>
<td>#{company.get_objectid.local_id}</td>
<td title="Voir"><a href="/referentials/#{referential.id}/companies/#{company.id}">#{company.name}</a></td>
<td></td>
diff --git a/spec/support/pundit/pundit_view_policy.rb b/spec/support/pundit/pundit_view_policy.rb
index 91be0624c..b8434cac0 100644
--- a/spec/support/pundit/pundit_view_policy.rb
+++ b/spec/support/pundit/pundit_view_policy.rb
@@ -1,16 +1,16 @@
module Pundit
module PunditViewPolicy
- 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 }
+ extend ActiveSupport::Concern
- allow(view).to receive(:policy) do |instance|
- ::Pundit.policy pundit_user, instance
+ included do
+ 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
end
end
end
diff --git a/spec/views/connection_links/index.html.erb_spec.rb b/spec/views/connection_links/index.html.erb_spec.rb
index 1f133e31e..a01380094 100644
--- a/spec/views/connection_links/index.html.erb_spec.rb
+++ b/spec/views/connection_links/index.html.erb_spec.rb
@@ -17,11 +17,9 @@ describe "/connection_links/index", :type => :view do
end
end
- 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
+ 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
diff --git a/spec/views/connection_links/show.html.erb_spec.rb b/spec/views/connection_links/show.html.erb_spec.rb
new file mode 100644
index 000000000..c04a4f3f1
--- /dev/null
+++ b/spec/views/connection_links/show.html.erb_spec.rb
@@ -0,0 +1,35 @@
+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 => '<div id="map"/>'.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
+
+# 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)}']")
+ 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']")
+ end
+
+end
+
diff --git a/spec/views/stop_areas/index.html.erb_spec.rb b/spec/views/stop_areas/index.html.erb_spec.rb
new file mode 100644
index 000000000..2dfae1bfd
--- /dev/null
+++ b/spec/views/stop_areas/index.html.erb_spec.rb
@@ -0,0 +1,25 @@
+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!(:q) { assign :q, Ransack::Search.new(Chouette::StopArea) }
+
+ before :each do
+ allow(view).to receive(:link_with_search).and_return("#")
+ 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
+
+end