aboutsummaryrefslogtreecommitdiffstats
path: root/spec/decorators
diff options
context:
space:
mode:
authorRobert2017-07-07 18:29:38 +0200
committerRobert2017-07-10 09:23:46 +0200
commit7c7451dc80b6f9b6092b3262fe524a8252309b1a (patch)
tree75914aa6f8901d13914fdec113c53dc7dedffcc3 /spec/decorators
parent39fe3258b19ee9c7cd01a7cd5b2344b39cb6ae3d (diff)
downloadchouette-core-7c7451dc80b6f9b6092b3262fe524a8252309b1a.tar.bz2
Fixes: #3478@2.5h
- Decorator Spec Setup `spec/support/decortor_helpers.rb` - Speced - Fixed
Diffstat (limited to 'spec/decorators')
-rw-r--r--spec/decorators/referential_decorator_spec.rb76
1 files changed, 76 insertions, 0 deletions
diff --git a/spec/decorators/referential_decorator_spec.rb b/spec/decorators/referential_decorator_spec.rb
new file mode 100644
index 000000000..5de6b7e95
--- /dev/null
+++ b/spec/decorators/referential_decorator_spec.rb
@@ -0,0 +1,76 @@
+RSpec.describe ReferentialDecorator, type: [:helper, :decorator] do
+
+ let( :object ){ build_stubbed :referential }
+ let( :referential ){ object }
+ let( :user ){ build_stubbed :user }
+
+ describe 'delegation' do
+ it 'delegates all' do
+ %i{xx xxx anything save!}.each do |method|
+ expect( object ).to receive(method)
+ end
+ # Almost as powerful as Quicktest :P
+ %i{xx xxx anything save!}.each do |method|
+ subject.send method
+ end
+ end
+ end
+
+ describe 'action links for' 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)])
+ 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_hrefs.to eq([
+ referential_time_tables_path(object),
+ ])
+ end
+ end
+ context 'all rights and same organisation' do
+
+ let( :user ){ build_stubbed :allmighty_user, organisation: referential.organisation }
+
+ 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),
+ archive_referential_path(object),
+ referential_path(object)
+ ])
+ end
+ end
+ end
+
+ 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)])
+ 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_hrefs.to eq([
+ referential_time_tables_path(object),
+ ])
+ end
+ end
+ end
+ end
+
+
+end