From b9b8abc826fb542c1b4f65a796e2381f56cfe411 Mon Sep 17 00:00:00 2001 From: Vlatka Pavisic Date: Wed, 22 Mar 2017 15:34:05 +0100 Subject: Refs #2902 : Referential#(un)archive policy check --- spec/controllers/referentials_controller_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spec/controllers/referentials_controller_spec.rb') diff --git a/spec/controllers/referentials_controller_spec.rb b/spec/controllers/referentials_controller_spec.rb index 442a10bbd..1b4533fca 100644 --- a/spec/controllers/referentials_controller_spec.rb +++ b/spec/controllers/referentials_controller_spec.rb @@ -4,4 +4,23 @@ describe ReferentialsController, :type => :controller do login_user + let(:referential) { Referential.first } + let(:organisation) { create :organisation } + let(:other_referential) { create :referential, organisation: organisation } + + describe 'PUT archive' do + context "user's organisation matches referential's organisation" do + it 'returns http success' do + put :archive, id: referential.id + expect(response).to have_http_status(302) + end + end + + context "user's organisation doesn't match referential's organisation" do + it 'raises a ActiveRecord::RecordNotFound' do + expect { put :archive, id: other_referential.id }.to raise_error(ActiveRecord::RecordNotFound) + end + end + end + end -- cgit v1.2.3