aboutsummaryrefslogtreecommitdiffstats
path: root/spec/decorators
diff options
context:
space:
mode:
authorZog2018-01-22 09:54:20 +0100
committerZog2018-01-25 17:18:01 +0100
commitff5d96b530a41669c394b7b0dc138e29da48e97d (patch)
treecc731e14383ef8f47302478faebac493dadacdf8 /spec/decorators
parent872f9476971d3bde6e6f470153af09ed87af1b28 (diff)
downloadchouette-core-ff5d96b530a41669c394b7b0dc138e29da48e97d.tar.bz2
Refs #5586 @2h; Fix specs
Diffstat (limited to 'spec/decorators')
-rw-r--r--spec/decorators/referential_decorator_spec.rb52
1 files changed, 37 insertions, 15 deletions
diff --git a/spec/decorators/referential_decorator_spec.rb b/spec/decorators/referential_decorator_spec.rb
index 9e34a0109..efc438132 100644
--- a/spec/decorators/referential_decorator_spec.rb
+++ b/spec/decorators/referential_decorator_spec.rb
@@ -21,8 +21,8 @@ RSpec.describe ReferentialDecorator, type: [:helper, :decorator] do
context 'unarchived referential' do
context 'no rights' do
- it 'has only a Calendar action' do
- expect_action_link_hrefs.to eq([referential_time_tables_path(object)])
+ it 'has only show and Calendar actions' do
+ expect_action_link_hrefs.to eq([[object], referential_time_tables_path(object)])
end
end
@@ -31,8 +31,9 @@ RSpec.describe ReferentialDecorator, type: [:helper, :decorator] do
let( :user ){ build_stubbed :allmighty_user }
it 'has only default actions' do
- expect_action_link_elements.to be_empty
+ expect_action_link_elements.to eq ["Consulter", "Calendriers", "Dupliquer"]
expect_action_link_hrefs.to eq([
+ [object],
referential_time_tables_path(object),
new_referential_path(from: object)
])
@@ -41,16 +42,36 @@ RSpec.describe ReferentialDecorator, type: [:helper, :decorator] do
context 'all rights and same organisation' do
let( :user ){ build_stubbed :allmighty_user, organisation: referential.organisation }
+ let( :action){ :index }
+ context "on index" do
+ it 'has corresponding actions' do
+ expect_action_link_elements(action).to eq ["Consulter", "Editer", "Calendriers", "Dupliquer", "Valider", "Conserver","<span class=\"fa fa-trash mr-xs\"></span>Supprimer"]
+ expect_action_link_hrefs(action).to eq([
+ [object],
+ [:edit, object],
+ referential_time_tables_path(object),
+ new_referential_path(from: object),
+ referential_select_compliance_control_set_path(object),
+ archive_referential_path(object),
+ referential_path(object)
+ ])
+ end
+ end
- it 'has all actions' do
- expect_action_link_elements.to eq(%w{Purger})
- expect_action_link_hrefs.to eq([
- referential_time_tables_path(object),
- new_referential_path(from: object),
- referential_select_compliance_control_set_path(object),
- archive_referential_path(object),
- referential_path(object)
- ])
+ context "on show" do
+ let( :action){ :show }
+ it 'has corresponding actions' do
+ expect_action_link_elements(action).to eq ["Editer", "Calendriers", "Dupliquer", "Valider", "Conserver", "Purger", "<span class=\"fa fa-trash mr-xs\"></span>Supprimer"]
+ expect_action_link_hrefs(action).to eq([
+ [:edit, object],
+ referential_time_tables_path(object),
+ new_referential_path(from: object),
+ referential_select_compliance_control_set_path(object),
+ archive_referential_path(object),
+ "#",
+ referential_path(object)
+ ])
+ end
end
end
end
@@ -58,16 +79,17 @@ RSpec.describe ReferentialDecorator, type: [:helper, :decorator] do
context 'archived referential' do
before { referential.archived_at = 42.seconds.ago }
context 'no rights' do
- it 'has only a Calendar action' do
- expect_action_link_hrefs.to eq([referential_time_tables_path(object)])
+ it 'has only ahow and calendar actions' do
+ expect_action_link_hrefs.to eq([[object], referential_time_tables_path(object)])
end
end
context 'all rights and different organisation' do
let( :user ){ build_stubbed :allmighty_user }
it 'has only default actions' do
- expect_action_link_elements.to be_empty
+ expect_action_link_elements.to eq ["Consulter", "Calendriers", "Dupliquer"]
expect_action_link_hrefs.to eq([
+ [object],
referential_time_tables_path(object),
new_referential_path(from: object)
])