spec/features/users/sign_in_spec.rb in cadenero-0.0.2.a3 vs spec/features/users/sign_in_spec.rb in cadenero-0.0.2.b1

- old
+ new

@@ -1,8 +1,10 @@ require 'spec_helper' +require 'cadenero/testing_support/subdomain_helpers' + feature 'User sign in' do - extend SubdomainHelpers + extend Cadenero::TestingSupport::SubdomainHelpers def create_account_user @user ||= { email: "user@example.com", password: "password", password_confirmation: "password" } end @@ -21,11 +23,13 @@ end let(:account) { FactoryGirl.create(:account_with_schema) } let(:errors_redirect_ro_sign_in) {{errors: %Q{Please sign in. posting the user json credentials as: {"user": {"email": "testy2@example.com", "password": "changeme"}} to /v1/sessions}, links: "/v1/sessions"}.to_json} let(:errors_invalid_email_or_password) {{ errors: {user:["Invalid email or password"]} }.to_json} + let(:errors_invalid_subdomain) {{ errors: {subdomain:["Invalid subdomain"]} }.to_json} let(:sessions_url) { "http://#{account.subdomain}.example.com/v1/sessions" } + let(:error_url) { "http://error.example.com/v1/sessions" } let(:root_url) { "http://#{account.subdomain}.example.com/v1" } within_account_subdomain do scenario "signs in as an account owner successfully" do get cadenero.v1_root_url(:subdomain => account.subdomain) @@ -72,14 +76,20 @@ sign_in_user sessions_url, { email: "foo@example.com", password: "password", password_confirmation: "password" } expect(last_response.status).to eq 422 expect(last_response.body).to eql(errors_invalid_email_or_password) end - it "cannot sign in if not a part of this subdomain" do + it "cannot sign in if not a part of an existing subdomain" do other_account = FactoryGirl.create(:account) get cadenero.v1_root_url(:subdomain => account.subdomain) expect(last_response.body).to eql(errors_redirect_ro_sign_in) sign_in_user sessions_url, { email: other_account.owner.email, password: "", password_confirmation: "" } expect(last_response.status).to eq 422 expect(last_response.body).to eql(errors_invalid_email_or_password) - end + end + + it "cannot sign in if the subdomain does not exist" do + sign_in_user error_url, account_user(account.owner) + expect(last_response.status).to eq 422 + expect(last_response.body).to eql(errors_invalid_subdomain) + end end \ No newline at end of file