Skip to content

Commit

Permalink
Fixes for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aplegatt committed Jul 3, 2020
1 parent 169dac4 commit 8e9caa0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
subject { get :authorization_failure }

context 'user signed in' do
before { allow(controller).to receive(:spree_current_user) { build_stubbed(:user) } }
before { allow(controller).to receive(:spree_current_user) { create(:user) } }

it { is_expected.to render_template 'authorization_failure' }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/spree/products_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.describe Spree::ProductsController, type: :controller do
let!(:product) { create(:product, available_on: 1.year.from_now) }
let!(:user) { build_stubbed(:user, spree_api_key: 'fake') }
let!(:user) { create(:user, spree_api_key: 'fake') }

subject(:request) { get :show, params: { id: product.to_param }}

Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/sign_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
fill_in 'Email', with: user.email
fill_in 'Password', with: 'secret'
click_button 'Log in'
within '.user-menu' do
within '.navbar .dropdown-menu' do
expect(page).to have_text '[email protected]'
end
expect(current_path).to eq '/admin/orders'
Expand Down
12 changes: 6 additions & 6 deletions spec/features/sign_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
fill_in 'Password', with: user.password
click_button 'Log in'

within '.user-menu' do
within '.navbar .dropdown-menu' do
expect(page).to have_text '[email protected]'
end
expect(current_path).to eq '/admin/orders'
end

xit "should store the user previous location" do
it 'should store the user previous location' do
visit spree.account_path
fill_in "Email", with: @user.email
fill_in "Password", with: @user.password
click_button "Login"
expect(current_path).to eq "/account"
fill_in 'Email', with: @user.email
fill_in 'Password', with: @user.password
click_button 'Log in'
expect(current_path).to eq '/account'
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
require 'spec_helper'

def try_spree_current_user
if respond_to?(:spree_current_user)
spree_current_user
elsif respond_to?(:current_spree_user)
current_spree_user
end
end

describe 'Storefront API v2 Account Confirmation spec', type: :request do
describe 'account_confirmations#show' do

Expand Down Expand Up @@ -32,7 +40,7 @@
end

it 'return JSON API payload of error' do
expect(JSON.parse(response.body)['error']).to eq("Confirmation token is invalid")
expect(JSON.parse(response.body)['error']).to eq('Confirmation token is invalid')
end
end

Expand Down
37 changes: 22 additions & 15 deletions spec/requests/spree/api/v2/storefront/account_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
require 'spec_helper'

def try_spree_current_user
if respond_to?(:spree_current_user)
spree_current_user
elsif respond_to?(:current_spree_user)
current_spree_user
end
end

describe 'Storefront API v2 Account spec', type: :request do
describe 'account#create' do
before { post '/api/v2/storefront/account', params: params }
Expand All @@ -8,9 +16,9 @@
let(:params) do
{
"user": {
"email": "[email protected]",
"password": "password123",
"password_confirmation": "password123"
"email": '[email protected]',
"password": 'password123',
"password_confirmation": 'password123'
}
}
end
Expand All @@ -26,9 +34,9 @@
let(:params) do
{
"user": {
"email": "[email protected]",
"password": "password123",
"password_confirmation": ""
"email": '[email protected]',
"password": 'password123',
"password_confirmation": ''
}
}
end
Expand All @@ -37,13 +45,12 @@
expect(JSON.parse(response.body)['error']).to eq("Password Confirmation doesn't match Password")
end
end

end

describe 'account#update' do
include_context 'API v2 tokens'

let!(:user) { create(:user_with_addresses) }
let!(:user) { create(:user_with_addresses) }
let(:headers) { headers_bearer }

before { patch '/api/v2/storefront/account', params: params, headers: headers }
Expand All @@ -52,9 +59,9 @@
let(:params) do
{
"user": {
"email": "[email protected]",
"password": "password123",
"password_confirmation": "password123"
"email": '[email protected]',
"password": 'password123',
"password_confirmation": 'password123'
}
}
end
Expand All @@ -70,7 +77,7 @@
let(:params) do
{
"user": {
"email": "[email protected]"
"email": '[email protected]'
}
}
end
Expand All @@ -86,9 +93,9 @@
let(:params) do
{
"user": {
"email": "[email protected]",
"password": "password123",
"password_confirmation": ""
"email": '[email protected]',
"password": 'password123',
"password_confirmation": ''
}
}
end
Expand Down

0 comments on commit 8e9caa0

Please sign in to comment.