diff --git a/test/integration/api_test.rb b/test/integration/api_test.rb index a9c95aad..712af53c 100644 --- a/test/integration/api_test.rb +++ b/test/integration/api_test.rb @@ -2,9 +2,23 @@ require 'gds_api/panopticon' class ApiAcceptanceTest < ActionDispatch::IntegrationTest + def server + @server ||= startup_server + end + + def startup_server + server = Capybara::Server.new(Capybara.app) + server.boot + server + end + + def create_test_user + FactoryGirl.create(:user, name: "Test", email: "test@example.com", uid: 123) + end + test "Can create an artefact via the api" do create_test_user - api_client = GdsApi::Panopticon.new(nil, endpoint_url: @server.url(""), timeout: 5) + api_client = GdsApi::Panopticon.new(nil, endpoint_url: server.url(""), timeout: 5) artefact_fixture = {slug: "foo", name: "Foo", owning_app: "Test", kind: "custom-application", need_id: 1} created = nil diff --git a/test/integration_test_helper.rb b/test/integration_test_helper.rb index 5327f8f8..3e92fdc2 100644 --- a/test/integration_test_helper.rb +++ b/test/integration_test_helper.rb @@ -14,24 +14,12 @@ def setup WebMock.allow_net_connect! stub_request(:get, /assets\.test\.gov\.uk/).to_return(status: 404) - - @server = startup_server end def teardown DatabaseCleaner.clean WebMock.reset! # Not entirely sure whether this happens anyway end - - def startup_server - server = Capybara::Server.new(Capybara.app) - server.boot - server - end - - def create_test_user - FactoryGirl.create(:user, name: "Test", email: "test@example.com", uid: 123) - end end Capybara.app = Rack::Builder.new do