diff options
| author | cedricnjanga | 2017-12-05 23:37:17 +0100 | 
|---|---|---|
| committer | cedricnjanga | 2017-12-05 23:37:17 +0100 | 
| commit | 00fa87ab96185bbcdc1ce2f1d19230e5a1dcc77f (patch) | |
| tree | 1be8a7bb6de44baa6e19bdaaf8d51c05e170e73d /spec/controllers/api | |
| parent | 9f1aa4d40d7d968963dae5799e15ad5da4cbcbc5 (diff) | |
| download | chouette-core-00fa87ab96185bbcdc1ce2f1d19230e5a1dcc77f.tar.bz2 | |
Add some changes according to PR review
Diffstat (limited to 'spec/controllers/api')
3 files changed, 94 insertions, 37 deletions
| diff --git a/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb b/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb deleted file mode 100644 index 1c3784807..000000000 --- a/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -RSpec.describe Api::V1::ComplianceCheckSetsController, type: :controller do -  include_context 'iboo authenticated api user' - -  describe "POST #validate" do -    let(:check_set) { create(:compliance_check_set) } - -    it "calls #update_status on the ComplianceCheckSet" do -      expect_any_instance_of(ComplianceCheckSet).to receive(:update_status) - -      patch :validated, id: check_set.id -    end - -    context "responds with" do -      render_views - -      it "object JSON on #update_status true" do -        allow_any_instance_of( -          ComplianceCheckSet -        ).to receive(:update_status).and_return(true) - -        patch :validated, id: check_set.id - -        expect(JSON.parse(response.body)['id']).to eq(check_set.id) -      end - -      it "error JSON on #update_status false" do -        allow_any_instance_of( -          ComplianceCheckSet -        ).to receive(:update_status).and_return(false) - -        patch :validated, id: check_set.id - -        expect(response.body).to include('error') -      end -    end -  end -end diff --git a/spec/controllers/api/v1/internals/compliance_check_sets_controller_spec.rb b/spec/controllers/api/v1/internals/compliance_check_sets_controller_spec.rb new file mode 100644 index 000000000..90401611c --- /dev/null +++ b/spec/controllers/api/v1/internals/compliance_check_sets_controller_spec.rb @@ -0,0 +1,52 @@ +require 'rails_helper' + +RSpec.describe Api::V1::Internals::ComplianceCheckSetsController, type: :controller do +  let(:check_set_1) { create :compliance_check_set } +  let(:check_set_2) { create :compliance_check_set } + +  describe "GET #notify_parent" do +    context 'unauthenticated' do +      include_context 'iboo wrong authorisation internal api' + +      it 'should not be successful' do +        get :notify_parent, id: check_set_1.id +        expect(response).to have_http_status 401 +      end +    end + +    context 'authenticated' do +      include_context 'iboo authenticated internal api' + +      describe "with existing record" do + +        before(:each) do  +          get :notify_parent, id: check_set_2.id +        end + +        it 'should be successful' do +          expect(response).to have_http_status 200 +        end + +        describe "that has a parent" do   +          xit "calls #notify_parent on the import" do +            expect(check_set_2.reload.notified_parent_at).not_to be_nil +          end +        end + +        describe "that does not have a parent" do +          xit "should not be successful" do +            expect(response.body).to include("error") +          end +        end +         +      end + +      describe "with non existing record" do +        it "should throw an error" do +          get :notify_parent, id: 47 +          expect(response.body).to include("error") +        end +      end +    end +  end +end diff --git a/spec/controllers/api/v1/internals/netex_imports_controller_spec.rb b/spec/controllers/api/v1/internals/netex_imports_controller_spec.rb new file mode 100644 index 000000000..1fb898c06 --- /dev/null +++ b/spec/controllers/api/v1/internals/netex_imports_controller_spec.rb @@ -0,0 +1,42 @@ +RSpec.describe Api::V1::Internals::NetexImportsController, type: :controller do +  let(:import_1) { create :netex_import } +  let(:import_2) { create :netex_import } + +  describe "GET #notify_parent" do +    context 'unauthenticated' do +      include_context 'iboo wrong authorisation internal api' + +      it 'should not be successful' do +        get :notify_parent, id: import_1.id +        expect(response).to have_http_status 401 +      end +    end + +    context 'authenticated' do +      include_context 'iboo authenticated internal api' + +      describe "with existing record" do + +        before(:each) do  +          get :notify_parent, id: import_2.id +        end + +        it 'should be successful' do +          expect(response).to have_http_status 200 +        end +         +        it "calls #notify_parent on the import" do +          expect(import_2.reload.notified_parent_at).not_to be_nil +        end +      end + +      describe "with non existing record" do +        it "should throw an error" do +          get :notify_parent, id: 47 +          expect(response.body).to include("error") +        end +      end +    end +  end +end + | 
