Skip to content

Commit 42c6d5a

Browse files
Add Customer Support Email Address (spree#10035)
1 parent 75d9646 commit 42c6d5a

File tree

10 files changed

+65
-35
lines changed

10 files changed

+65
-35
lines changed

api/app/helpers/spree/api/api_helpers.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ def required_fields_for(model)
161161

162162
@@store_attributes = [
163163
:id, :name, :url, :meta_description, :meta_keywords, :seo_title,
164-
:mail_from_address, :default_currency, :code, :default,
165-
:facebook, :twitter, :instagram
164+
:mail_from_address, :customer_support_email, :default_currency,
165+
:code, :default, :facebook, :twitter, :instagram
166166
]
167167

168168
@@tag_attributes = [:id, :name]

api/spec/controllers/spree/api/v1/stores_controller_spec.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ module Spree
3333
'meta_description' => nil,
3434
'meta_keywords' => nil,
3535
'seo_title' => nil,
36-
'mail_from_address' => '[email protected]',
36+
'mail_from_address' => '[email protected]',
37+
'customer_support_email' => '[email protected]',
3738
'default_currency' => 'USD',
3839
'code' => store.code,
3940
'default' => true,
@@ -48,7 +49,8 @@ module Spree
4849
'meta_description' => nil,
4950
'meta_keywords' => nil,
5051
'seo_title' => nil,
51-
'mail_from_address' => '[email protected]',
52+
'mail_from_address' => '[email protected]',
53+
'customer_support_email' => '[email protected]',
5254
'default_currency' => 'USD',
5355
'code' => non_default_store.code,
5456
'default' => false,
@@ -69,7 +71,8 @@ module Spree
6971
'meta_description' => nil,
7072
'meta_keywords' => nil,
7173
'seo_title' => nil,
72-
'mail_from_address' => '[email protected]',
74+
'mail_from_address' => '[email protected]',
75+
'customer_support_email' => '[email protected]',
7376
'default_currency' => 'USD',
7477
'code' => store.code,
7578
'default' => true,
@@ -85,6 +88,7 @@ module Spree
8588
name: 'Hack0rz',
8689
url: 'spree123.example.com',
8790
mail_from_address: '[email protected]',
91+
customer_support_email: '[email protected]',
8892
default_currency: 'USD'
8993
}
9094
api_post :create, store: store_hash
@@ -94,12 +98,14 @@ module Spree
9498
it 'I can update an existing store' do
9599
store_hash = {
96100
url: 'spree123.example.com',
97-
mail_from_address: '[email protected]'
101+
mail_from_address: '[email protected]',
102+
customer_support_email: '[email protected]',
98103
}
99104
api_put :update, id: store.id, store: store_hash
100105
expect(response.status).to eq(200)
101106
expect(store.reload.url).to eql 'spree123.example.com'
102107
expect(store.reload.mail_from_address).to eql '[email protected]'
108+
expect(store.reload.customer_support_email).to eql '[email protected]'
103109
end
104110

105111
context 'deleting a store' do

backend/app/views/spree/admin/stores/_form.html.erb

+14-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="card">
44
<div class="card-header">
55
<h1 class="card-title mb-0 h5">
6-
Basic Information
6+
<%= Spree.t(:basic_information) %>
77
</h1>
88
</div>
99
<div class="card-body">
@@ -13,7 +13,7 @@
1313
<%= f.error_message_on :name %>
1414
<% end %>
1515
<%= f.field_container :url, class: ['form-group'] do %>
16-
<%= f.label :url, Spree.t(:url) %>
16+
<%= f.label :url, raw(Spree.t(:url) + required_span_tag) %>
1717
<%= f.text_field :url, class: 'form-control', required: true %>
1818
<%= f.error_message_on :url %>
1919
<% end %>
@@ -25,12 +25,12 @@
2525
<div class="card">
2626
<div class="card-header">
2727
<h1 class="card-title mb-0 h5">
28-
SEO
28+
<%= Spree.t(:seo) %>
2929
</h1>
3030
</div>
3131
<div class="card-body">
3232
<%= f.field_container :seo_title, class: ['form-group'] do %>
33-
<%= f.label :seo_title, Spree.t(:seo_title) %>
33+
<%= f.label :seo_title, Spree.t(:seo_title) %>
3434
<%= f.text_field :seo_title, class: 'form-control' %>
3535
<%= f.error_message_on :seo_title %>
3636
<% end %>
@@ -52,15 +52,21 @@
5252
<div class="card">
5353
<div class="card-header">
5454
<h1 class="card-title mb-0 h5">
55-
Emails
55+
<%= Spree.t(:email).pluralize %>
5656
</h1>
5757
</div>
5858
<div class="card-body">
5959
<%= f.field_container :mail_from_address, class: ['form-group'] do %>
60-
<%= f.label :mail_from_address, Spree.t(:mail_from_address) %>
60+
<%= f.label :mail_from_address, raw(Spree.t(:mail_from_address) + required_span_tag) %>
6161
<%= f.text_field :mail_from_address, class: 'form-control', required: true %>
6262
<%= f.error_message_on :mail_from_address %>
6363
<% end %>
64+
65+
<%= f.field_container :customer_support_email, class: ['form-group'] do %>
66+
<%= f.label :customer_support_email, Spree.t(:customer_support_email) %>
67+
<%= f.text_field :customer_support_email, class: 'form-control' %>
68+
<%= f.error_message_on :customer_support_email %>
69+
<% end %>
6470
</div>
6571
</div>
6672

@@ -69,7 +75,7 @@
6975
<div class="card">
7076
<div class="card-header">
7177
<h1 class="card-title mb-0 h5">
72-
Internationalization
78+
<%= Spree.t(:internationalization) %>
7379
</h1>
7480
</div>
7581
<div class="card-body">
@@ -91,7 +97,7 @@
9197
<div class="card">
9298
<div class="card-header">
9399
<h1 class="card-title mb-0 h5">
94-
Social
100+
<%= Spree.t(:social) %>
95101
</h1>
96102
</div>
97103
<div class="card-body">

backend/spec/features/admin/configuration/general_settings_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
stub_authorization!
55

66
before do
7-
create(:store, name: 'Test Store', url: 'test.example.org', mail_from_address: 'test@example.org')
7+
create(:store, name: 'Test Store', url: 'test.example.com', mail_from_address: 'test@example.com')
88
visit spree.edit_admin_general_settings_path
99
end
1010

backend/spec/features/admin/configuration/stores_spec.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
click_link 'New Store'
3535
page.fill_in 'store_name', with: 'Spree Example Test'
3636
page.fill_in 'store_url', with: 'test.localhost'
37-
page.fill_in 'store_mail_from_address', with: '[email protected]'
37+
page.fill_in 'store_mail_from_address', with: '[email protected]'
38+
page.fill_in 'store_customer_support_email', with: '[email protected]'
3839
select2 'EUR', from: 'Currency'
3940
click_button 'Create'
4041

core/config/locales/en.yml

+8
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ en:
607607
balance_due: Balance Due
608608
base_amount: Base Amount
609609
base_percent: Base Percent
610+
basic_information: Basic Information
610611
bill_address: Bill Address
611612
billing: Billing
612613
billing_address: Billing Address
@@ -734,6 +735,7 @@ en:
734735
customer_return: Customer Return
735736
customer_returns: Customer Returns
736737
customer_search: Customer Search
738+
customer_support_email: Customer Support Email
737739
cut: Cut
738740
cvv: CVV
739741
cvv_response: CVV Response
@@ -831,6 +833,7 @@ en:
831833
extension: Extension
832834
extensions_directory: Extensions Directory
833835
existing_shipments: Existing shipments
836+
facebook: Facebook
834837
failed_payment_attempts: Failed Payment Attempts
835838
filename: Filename
836839
fill_in_customer_info: Please fill in customer info
@@ -912,13 +915,15 @@ en:
912915
info_number_of_skus_not_shown:
913916
one: "and one other"
914917
other: "and %{count} others"
918+
instagram: Instagram
915919
instructions_to_reset_password: Please enter your email on the form below
916920
insufficient_stock: Insufficient stock available, only %{on_hand} remaining
917921
insufficient_stock_item_quantity: Insufficient stock quantity available
918922
insufficient_stock_lines_present: Some line items in this order have insufficient quantity.
919923
intercept_email_address: Intercept Email Address
920924
intercept_email_instructions: Override email recipient and replace with this address.
921925
internal_name: Internal Name
926+
internationalization: Internationalization
922927
invalid_credit_card: Invalid credit card.
923928
invalid_exchange_variant: Invalid exchange variant.
924929
invalid_payment_provider: Invalid payment provider.
@@ -1423,6 +1428,7 @@ en:
14231428
select_a_store_credit_reason: Select a reason for the store credit
14241429
select_stock: Select stock
14251430
selected_quantity_not_available: ! 'selected of %{item} is not available.'
1431+
seo: SEO
14261432
send_copy_of_all_mails_to: Send Copy of All Mails To
14271433
send_mails_as: Send Mails As
14281434
seo_title: SEO title
@@ -1487,6 +1493,7 @@ en:
14871493
skus: SKUs
14881494
slug: Slug
14891495
source: Source
1496+
social: Social
14901497
special_instructions: Special Instructions
14911498
split: Split
14921499
spree_gateway_error_flash_for_checkout: There was a problem with your payment information. Please check your information and try again.
@@ -1658,6 +1665,7 @@ en:
16581665
tree: Tree
16591666
type: Type
16601667
type_to_search: Type to search
1668+
twitter: Twitter
16611669
unable_to_connect_to_gateway: Unable to connect to gateway.
16621670
unable_to_create_reimbursements: Unable to create reimbursements because there are items pending manual intervention.
16631671
under_price: Under %{price}

core/db/default/spree/stores.rb

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# Possibly already created by a migration.
22
unless Spree::Store.default.persisted?
33
Spree::Store.new do |s|
4-
s.name = 'Spree Demo Site'
5-
s.code = 'spree'
6-
s.url = Rails.application.routes.default_url_options[:host] || 'demo.spreecommerce.org'
7-
s.mail_from_address = '[email protected]'
8-
s.default_currency = 'USD'
9-
s.seo_title = 'Spree Commerce Demo Shop'
10-
s.meta_description = 'This is the new Spree UX DEMO | OVERVIEW: http://bit.ly/new-spree-ux | DOCS: http://bit.ly/spree-ux-customization-docs | CONTACT: https://spreecommerce.org/contact/'
11-
s.facebook = 'spreecommerce'
12-
s.twitter = 'spreecommerce'
13-
s.instagram = 'spreecommerce'
4+
s.name = 'Spree Demo Site'
5+
s.code = 'spree'
6+
s.url = Rails.application.routes.default_url_options[:host] || 'demo.spreecommerce.org'
7+
s.mail_from_address = '[email protected]'
8+
s.customer_support_email = '[email protected]'
9+
s.default_currency = 'USD'
10+
s.seo_title = 'Spree Commerce Demo Shop'
11+
s.meta_description = 'This is the new Spree UX DEMO | OVERVIEW: http://bit.ly/new-spree-ux | DOCS: http://bit.ly/spree-ux-customization-docs | CONTACT: https://spreecommerce.org/contact/'
12+
s.facebook = 'spreecommerce'
13+
s.twitter = 'spreecommerce'
14+
s.instagram = 'spreecommerce'
1415
end.save!
1516
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class AddCustomerSupportEmailToSpreeStore < ActiveRecord::Migration[6.0]
2+
def change
3+
unless column_exists?(:spree_stores, :customer_support_email)
4+
add_column :spree_stores, :customer_support_email, :string
5+
end
6+
end
7+
end

core/lib/spree/permitted_attributes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module PermittedAttributes
9898

9999
@@store_attributes = [:name, :url, :seo_title, :code, :meta_keywords,
100100
:meta_description, :default_currency, :mail_from_address,
101-
:facebook, :twitter, :instagram, :default_locale]
101+
:customer_support_email, :facebook, :twitter, :instagram, :default_locale]
102102

103103
@@store_credit_attributes = %i[amount currency category_id memo]
104104

Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
FactoryBot.define do
22
factory :store, class: Spree::Store do
3-
sequence(:code) { |i| "spree_#{i}" }
4-
name { 'Spree Test Store' }
5-
url { 'www.example.com' }
6-
mail_from_address { '[email protected]' }
7-
default_currency { 'USD' }
8-
facebook { 'spreecommerce' }
9-
twitter { 'spreecommerce' }
10-
instagram { 'spreecommerce' }
3+
sequence(:code) { |i| "spree_#{i}" }
4+
name { 'Spree Test Store' }
5+
url { 'www.example.com' }
6+
mail_from_address { '[email protected]' }
7+
customer_support_email { '[email protected]' }
8+
default_currency { 'USD' }
9+
facebook { 'spreecommerce' }
10+
twitter { 'spreecommerce' }
11+
instagram { 'spreecommerce' }
1112
end
1213
end

0 commit comments

Comments
 (0)