Allow updating of account settings from account tabs interface

This commit is contained in:
Rob Harrington
2017-05-31 12:36:35 +10:00
parent 4ef97aa418
commit fb5784fbda
7 changed files with 42 additions and 13 deletions

View File

@@ -1,2 +0,0 @@
%script{ type: "text/ng-template", id: "account/details.html" }
Details

View File

@@ -0,0 +1,6 @@
= render :partial => 'spree/shared/error_messages', :locals => { :target => @user }
%h3= t('.account_settings')
= form_for Spree::User.new, :as => @user, :url => spree.user_path(@user), :method => :put do |f|
= render :partial => 'spree/shared/user_form', :locals => { :f => f }
%p
= f.submit t(:update), :class => 'button primary'

View File

@@ -0,0 +1,2 @@
%script{ type: "text/ng-template", id: "account/settings.html" }
= render 'form'

View File

@@ -1,8 +1,3 @@
.darkswarm
.row
= render :partial => 'spree/shared/error_messages', :locals => { :target => @user }
%h1= t(:editing_user)
= form_for Spree::User.new, :as => @user, :url => spree.user_path(@user), :method => :put do |f|
= render :partial => 'spree/shared/user_form', :locals => { :f => f }
%p
= f.submit t(:update), :class => 'button primary'
= render 'form'

View File

@@ -12,12 +12,11 @@
= accurate_title
%span.account-summary{"data-hook" => "account_summary"}
= @user.email
(#{link_to t(:edit), spree.edit_account_path})
= render 'orders'
= render 'cards'
= render 'transactions'
= render 'cards'
= render 'settings'
.row.tabset-ctrl#account-tabs{ style: 'margin-bottom: 100px', navigate: 'true', selected: 'orders', prefix: 'account' }
.small.12.medium-3.columns.tab{ name: "orders" }
@@ -26,8 +25,8 @@
%a{ href: 'javascript:void(0)' }=t('.tabs.cards')
.small.12.medium-3.columns.tab{ name: "transactions" }
%a{ href: 'javascript:void(0)' }=t('.tabs.transactions')
.small.12.medium-3.columns.tab{ name: "details" }
%a{ href: 'javascript:void(0)' }=t('.tabs.details')
.small.12.medium-3.columns.tab{ name: "settings" }
%a{ href: 'javascript:void(0)' }=t('.tabs.settings')
.small-12.columns.tab-view
= render partial: "shared/footer"

View File

@@ -2187,12 +2187,14 @@ Please follow the instructions there to make your enterprise visible on the Open
weight: Weight (per kg)
zipcode: Postcode
users:
form:
account_settings: Account Settings
show:
tabs:
orders: Orders
cards: Credit Cards
transactions: Transactions
details: Details
settings: Account Settings
orders:
open_orders: Open Orders
past_orders: Past Orders

View File

@@ -0,0 +1,27 @@
require 'spec_helper'
feature "Account Settings", js: true do
include AuthenticationWorkflow
describe "as a logged in user" do
let(:user) { create(:user) }
before do
quick_login_as user
end
it "allows me to update my account details" do
visit "/account"
click_link I18n.t('spree.users.show.tabs.settings')
expect(page).to have_content I18n.t('spree.users.form.account_settings')
fill_in 'user_email', with: 'new@email.com'
click_button I18n.t(:update)
expect(find(".alert-box.success").text.strip).to eq "#{I18n.t(:account_updated)} ×"
user.reload
expect(user.email).to eq 'new@email.com'
end
end
end