From 00fa87ab96185bbcdc1ce2f1d19230e5a1dcc77f Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Tue, 5 Dec 2017 23:37:17 +0100 Subject: Add some changes according to PR review --- .../compliance_check_sets_controller_spec.rb | 52 ++++++++++++++++++++++ .../v1/internals/netex_imports_controller_spec.rb | 42 +++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 spec/controllers/api/v1/internals/compliance_check_sets_controller_spec.rb create mode 100644 spec/controllers/api/v1/internals/netex_imports_controller_spec.rb (limited to 'spec/controllers/api/v1/internals') 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 + -- cgit v1.2.3