aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlatka pavisic2016-12-27 12:13:53 +0100
committervlatka pavisic2016-12-27 12:13:53 +0100
commit08b68565fb7f82bc7754bd62ad3f72efca6ea62d (patch)
tree8ead4709d3ba3378f8bfb044ae05efb06914fde3
parent28be322127478599c138a08e818db37fd5f3cd25 (diff)
downloadchouette-core-08b68565fb7f82bc7754bd62ad3f72efca6ea62d.tar.bz2
Refs #2260 : LinePolicy changes
-rw-r--r--app/policies/line_policy.rb4
-rw-r--r--app/views/lines/_lines.html.slim2
-rw-r--r--app/views/referential_lines/_lines.html.slim2
-rw-r--r--config/locales/actions.en.yml1
-rw-r--r--config/locales/actions.fr.yml1
-rw-r--r--spec/features/line_footnotes_spec.rb30
-rw-r--r--spec/features/lines_spec.rb7
-rw-r--r--spec/features/referential_lines_spec.rb7
8 files changed, 50 insertions, 4 deletions
diff --git a/app/policies/line_policy.rb b/app/policies/line_policy.rb
index 8ef2dcaed..9d1f55cf2 100644
--- a/app/policies/line_policy.rb
+++ b/app/policies/line_policy.rb
@@ -8,9 +8,9 @@ class LinePolicy < ApplicationPolicy
def create?
false
end
- def update? ; true end
+ def update? ; false end
def new? ; create? end
- def edit? ; true end
+ def edit? ; false end
def destroy? ; create? end
def update_footnote?; true end
end
diff --git a/app/views/lines/_lines.html.slim b/app/views/lines/_lines.html.slim
index cdb90bbba..a9f0f4a14 100644
--- a/app/views/lines/_lines.html.slim
+++ b/app/views/lines/_lines.html.slim
@@ -2,7 +2,7 @@
= table_builder @lines,
{ 'Oid' => Proc.new { |n| n.objectid.local_id }, @lines.human_attribute_name(:id) => 'id',
@lines.human_attribute_name(:number) => 'number', @lines.human_attribute_name(:name) => 'name', @lines.human_attribute_name(:network) => Proc.new { |n| n.try(:network).try(:name) }, @lines.human_attribute_name(:company) => Proc.new { |n| n.try(:company).try(:name) } },
- [:show, :edit, :delete],
+ [:show],
'table table-bordered'
.text-center
diff --git a/app/views/referential_lines/_lines.html.slim b/app/views/referential_lines/_lines.html.slim
index cdb90bbba..a9f0f4a14 100644
--- a/app/views/referential_lines/_lines.html.slim
+++ b/app/views/referential_lines/_lines.html.slim
@@ -2,7 +2,7 @@
= table_builder @lines,
{ 'Oid' => Proc.new { |n| n.objectid.local_id }, @lines.human_attribute_name(:id) => 'id',
@lines.human_attribute_name(:number) => 'number', @lines.human_attribute_name(:name) => 'name', @lines.human_attribute_name(:network) => Proc.new { |n| n.try(:network).try(:name) }, @lines.human_attribute_name(:company) => Proc.new { |n| n.try(:company).try(:name) } },
- [:show, :edit, :delete],
+ [:show],
'table table-bordered'
.text-center
diff --git a/config/locales/actions.en.yml b/config/locales/actions.en.yml
index a259ecb8a..1321e6761 100644
--- a/config/locales/actions.en.yml
+++ b/config/locales/actions.en.yml
@@ -4,6 +4,7 @@ en:
destroy: "Destroy"
search: "Search"
add: "Add new"
+ show: "See"
or: "or"
cancel: "Cancel"
search_hint: "Type in a search term"
diff --git a/config/locales/actions.fr.yml b/config/locales/actions.fr.yml
index 60daa21f7..6c3e22933 100644
--- a/config/locales/actions.fr.yml
+++ b/config/locales/actions.fr.yml
@@ -4,6 +4,7 @@ fr:
destroy: "Supprimer"
search: "Chercher"
add: "Ajouter"
+ show: "Voir"
or: "ou"
cancel: "Annuler"
search_hint: "Entrez un texte à rechercher"
diff --git a/spec/features/line_footnotes_spec.rb b/spec/features/line_footnotes_spec.rb
new file mode 100644
index 000000000..a3eab103a
--- /dev/null
+++ b/spec/features/line_footnotes_spec.rb
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe 'Line Footnotes', type: :feature do
+ login_user
+
+ let(:referential) { Referential.first }
+ #let!(:line_referential) { create :line_referential }
+ let!(:network) { create(:network) }
+ let!(:company) { create(:company) }
+ let!(:line) { create :line_with_stop_areas, network: network, company: company, line_referential: referential.line_referential }
+ let!(:footnotes) { Array.new(2) { create :footnote, line: line } }
+ subject { footnotes.first }
+
+ describe 'index' do
+ before(:each) { visit referential_line_footnotes_path(referential.line_referential, line) }
+
+ it 'displays line footnotes' do
+ expect(page).to have_content(subject.label)
+ expect(page).to have_content(subject.label)
+ end
+
+ it 'allows R and U in CRUD' do
+ expect(page).to have_content(I18n.t('actions.edit'))
+ expect(page).not_to have_content(I18n.t('actions.show')) # they're just displayed in index view
+ expect(page).not_to have_content(I18n.t('actions.destroy'))
+ expect(page).not_to have_content(I18n.t('actions.add'))
+ end
+ end
+end
diff --git a/spec/features/lines_spec.rb b/spec/features/lines_spec.rb
index dbc449ccc..4ecefab33 100644
--- a/spec/features/lines_spec.rb
+++ b/spec/features/lines_spec.rb
@@ -19,6 +19,13 @@ describe "Lines", :type => :feature do
expect(page).to have_content(lines.last.name)
end
+ it 'allows only R in CRUD' do
+ expect(page).to have_content(I18n.t('actions.show'))
+ expect(page).not_to have_content(I18n.t('actions.edit'))
+ expect(page).not_to have_content(I18n.t('actions.destroy'))
+ expect(page).not_to have_content(I18n.t('actions.add'))
+ end
+
context 'filtering' do
it 'supports filtering by name' do
fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.name
diff --git a/spec/features/referential_lines_spec.rb b/spec/features/referential_lines_spec.rb
index 7743ad67e..580891c69 100644
--- a/spec/features/referential_lines_spec.rb
+++ b/spec/features/referential_lines_spec.rb
@@ -13,6 +13,13 @@ describe 'ReferentialLines', type: :feature do
expect(page).to have_content(referential.lines.last.name)
end
+ it 'allows only R in CRUD' do
+ expect(page).to have_content(I18n.t('actions.show'))
+ expect(page).not_to have_content(I18n.t('actions.edit'))
+ expect(page).not_to have_content(I18n.t('actions.destroy'))
+ expect(page).not_to have_content(I18n.t('actions.add'))
+ end
+
context 'filtering' do
it 'supports filtering by name' do
fill_in 'q[name_or_number_or_objectid_cont]', with: referential.lines.first.name