Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4368 Admin panel - users - edit exist user - update address field always return 200 #4431

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#4368 acceptance test - edit addresses
  • Loading branch information
dborovsky committed Jul 1, 2022
commit 75ba9b2199f1208d9a21cec597c3739da249eb64
53 changes: 53 additions & 0 deletions backend/spec/features/admin/addresses_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

require 'spec_helper'
require 'pry'

describe 'Addresses', type: :feature do
stub_authorization!
let!(:country) { create(:country) }
let!(:user_a) { create(:user_with_addresses, email: 'a@example.com') }
let!(:user_b) { create(:user_with_addresses, email: 'b@example.com') }
let!(:admin_role) { create(:role, name: 'admin') }
let!(:user_role) { create(:role, name: 'user') }
let!(:store) { create(:store) }

before do
visit spree.admin_path
click_link 'Users'
end

context "editing addresses" do
before { click_link user_a.email }

it 'can edit user shipping address' do
allow(Spree.user_class).to receive(:find_by).and_call_original
allow(Spree.user_class).to receive(:find_by).with("1").and_return(user_a)

click_link "Addresses"

within("#admin_user_edit_addresses") do
fill_in "user_ship_address_attributes_address1", with: "1313 Mockingbird Ln"
click_button 'Update'
expect(page).to have_field('user_ship_address_attributes_address1', with: "1313 Mockingbird Ln")
end

expect(user_a.reload.ship_address.address1).to eq "1313 Mockingbird Ln"
end

it 'can edit user billing address' do
allow(Spree.user_class).to receive(:find_by).and_call_original
allow(Spree.user_class).to receive(:find_by).with("1").and_return(user_a)

click_link "Addresses"

within("#admin_user_edit_addresses") do
fill_in "user_bill_address_attributes_address1", with: "1313 Mockingbird Ln"
click_button 'Update'
expect(page).to have_field('user_bill_address_attributes_address1', with: "1313 Mockingbird Ln")
end

expect(user_a.reload.bill_address.address1).to eq "1313 Mockingbird Ln"
end
end
end
24 changes: 0 additions & 24 deletions backend/spec/features/admin/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,30 +197,6 @@
expect(user_a.reload.spree_roles).to be_empty
end

it 'can edit user shipping address' do
click_link "Addresses"

within("#admin_user_edit_addresses") do
fill_in "user_ship_address_attributes_address1", with: "1313 Mockingbird Ln"
click_button 'Update'
expect(page).to have_field('user_ship_address_attributes_address1', with: "1313 Mockingbird Ln")
end

expect(user_a.reload.ship_address.address1).to eq "1313 Mockingbird Ln"
end

it 'can edit user billing address' do
click_link "Addresses"

within("#admin_user_edit_addresses") do
fill_in "user_bill_address_attributes_address1", with: "1313 Mockingbird Ln"
click_button 'Update'
expect(page).to have_field('user_bill_address_attributes_address1', with: "1313 Mockingbird Ln")
end

expect(user_a.reload.bill_address.address1).to eq "1313 Mockingbird Ln"
end

it 'can edit the user password' do
fill_in 'user_password', with: 'welcome'
fill_in 'user_password_confirmation', with: 'welcome'
Expand Down