diff --git a/app/views/spaces/new.html.erb b/app/views/spaces/new.html.erb index 78232066a..4f7efa2ac 100644 --- a/app/views/spaces/new.html.erb +++ b/app/views/spaces/new.html.erb @@ -1,9 +1,5 @@ <%= form_with(model: space) do |form| %> <%= render "text_field", attribute: :name, form: form %> - <%= form.fields_for(:client, space.client || space.build_client) do |client_form|%> - <%= render "text_field", attribute: :name, form: client_form %> - <%- end %> - <%= form.submit %> <%- end %> diff --git a/spec/requests/spaces_controller_request_spec.rb b/spec/requests/spaces_controller_request_spec.rb index d4dce0e13..487e649e9 100644 --- a/spec/requests/spaces_controller_request_spec.rb +++ b/spec/requests/spaces_controller_request_spec.rb @@ -5,39 +5,6 @@ RSpec.describe SpacesController do include ActiveJob::TestHelper - describe "#show" do - subject(:perform_request) do - get url - test_response - end - - let(:space) { create(:space) } - let(:url) { polymorphic_url(space) } - - it { is_expected.to be_ok } - specify { perform_request && assert_select("##{dom_id(space)}") } - - context "with a branded domain" do - let(:space) { create(:space, branded_domain: "beta.example.com") } - - context "when accessing via the neighborhood url" do - it { is_expected.to redirect_to "http://beta.example.com" } - end - - context "when accessing via domain" do - before do - space - host! "beta.example.com" - end - - let(:url) { "http://beta.example.com" } - - it { is_expected.to be_ok } - specify { perform_request && assert_select("##{dom_id(space)}") } - end - end - end - path "/spaces" do include ApiHelpers::Path @@ -88,8 +55,42 @@ end end end + + describe "#show" do + subject(:perform_request) do + get url + test_response + end + + let(:space) { create(:space) } + let(:url) { polymorphic_url(space) } + + it { is_expected.to be_ok } + specify { perform_request && assert_select("##{dom_id(space)}") } + + context "with a branded domain" do + let(:space) { create(:space, branded_domain: "beta.example.com") } + + context "when accessing via the neighborhood url" do + it { is_expected.to redirect_to "http://beta.example.com" } + end + + context "when accessing via domain" do + before do + space + host! "beta.example.com" + end + + let(:url) { "http://beta.example.com" } + + it { is_expected.to be_ok } + specify { perform_request && assert_select("##{dom_id(space)}") } + end + end + end + describe "#destroy" do - context "as an Operator using the API" do + context "when an an Operator using the AP" do it "deletes the space and all it's other bits" do SystemTestSpace.prepare @@ -131,4 +132,24 @@ end end end + + describe "#new" do + subject(:result) do + sign_in(nil, user) + get polymorphic_path([:new, :space]) + response + end + + context "when not logged in" do + let(:user) { nil } + + it { is_expected.to be_not_found } + end + + context "when an Operator" do + let(:user) { create(:person, operator: true) } + + it { is_expected.to be_ok } + end + end end diff --git a/spec/support/auth_helpers.rb b/spec/support/auth_helpers.rb index d4cc07799..4c2ed773b 100644 --- a/spec/support/auth_helpers.rb +++ b/spec/support/auth_helpers.rb @@ -8,7 +8,7 @@ def sign_in(space, person) authentication_method.bump_one_time_password! - post(space_authenticated_session_path(space), + post(polymorphic_path([space, :authenticated_session].compact), params: {authenticated_session: { authentication_method_id: authentication_method.id, one_time_password: authentication_method.one_time_password