aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlatka Pavisic2017-03-23 11:23:06 +0100
committerVlatka Pavisic2017-03-23 11:23:17 +0100
commit1e9eca1d053a82f9b0a5e01f8222d4364736b946 (patch)
treeda883da011a1087f83ffe2682f380365fe29fd5a
parent05363428c5f519346fd6610ae5ca6c86ab0578b8 (diff)
downloadchouette-core-1e9eca1d053a82f9b0a5e01f8222d4364736b946.tar.bz2
Refs #2803 : Do not show edit link for archived referentials
-rw-r--r--app/views/referentials/show.html.slim2
-rw-r--r--spec/features/referentials_spec.rb24
2 files changed, 25 insertions, 1 deletions
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index 62a17ea1e..9ed63d516 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -3,7 +3,7 @@
@referential.name,
'Lorem ipsum dolor sit amet',
t('last_update', time: l(@referential.updated_at, format: :short)),
- link_to(t('actions.edit'), edit_referential_path(@referential), class: 'btn btn-default') do
+ @referential.archived? ? nil : link_to(t('actions.edit'), edit_referential_path(@referential), class: 'btn btn-default') do
/ Below is secundary actions & optional contents (filters, ...)
.row.mb-sm
diff --git a/spec/features/referentials_spec.rb b/spec/features/referentials_spec.rb
index 39c5adcd5..ebaf70bca 100644
--- a/spec/features/referentials_spec.rb
+++ b/spec/features/referentials_spec.rb
@@ -4,6 +4,8 @@ require 'spec_helper'
describe "Referentials", :type => :feature do
login_user
+ let(:referential) { Referential.first }
+
describe "index" do
# FIXME #823
@@ -33,6 +35,28 @@ describe "Referentials", :type => :feature do
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
+ end
+
describe "create" do
it "should" do