Skip to content

Commit e165e72

Browse files
committed
Enable API support for reverse_charge_status
Allows access to the reverse_charge_status attribute through existing store APIs.
1 parent 8433651 commit e165e72

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

api/lib/spree/api_configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def promotion_attributes=(value)
127127
preference :store_attributes, :array, default: [
128128
:id, :name, :url, :meta_description, :meta_keywords, :seo_title,
129129
:mail_from_address, :default_currency, :code, :default, :available_locales,
130-
:bcc_email
130+
:bcc_email, :reverse_charge_status
131131
]
132132

133133
preference :store_credit_history_attributes, :array, default: [

api/spec/requests/spree/api/stores_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module Spree::Api
3232
"meta_description" => nil,
3333
"meta_keywords" => nil,
3434
"seo_title" => nil,
35+
"reverse_charge_status" => 'disabled',
3536
"mail_from_address" => "solidus@example.org",
3637
"bcc_email" => nil,
3738
"default_currency" => nil,
@@ -46,6 +47,7 @@ module Spree::Api
4647
"meta_description" => nil,
4748
"meta_keywords" => nil,
4849
"seo_title" => nil,
50+
"reverse_charge_status" => 'disabled',
4951
"mail_from_address" => "solidus@example.org",
5052
"bcc_email" => nil,
5153
"default_currency" => nil,
@@ -65,6 +67,7 @@ module Spree::Api
6567
"meta_description" => nil,
6668
"meta_keywords" => nil,
6769
"seo_title" => nil,
70+
"reverse_charge_status" => 'disabled',
6871
"mail_from_address" => "solidus@example.org",
6972
"bcc_email" => nil,
7073
"default_currency" => nil,
@@ -112,6 +115,36 @@ module Spree::Api
112115
expect(response.status).to eq(204)
113116
end
114117
end
118+
119+
context "reverse_charge_status attribute" do
120+
it "can create a new store with reverse_charge_status" do
121+
store_hash = {
122+
code: "spree123",
123+
name: "Hack0rz",
124+
url: "spree123.example.com",
125+
mail_from_address: "me@example.com",
126+
reverse_charge_status: "enabled"
127+
}
128+
post spree.api_stores_path, params: { store: store_hash }
129+
expect(response.status).to eq(201)
130+
expect(json_response["reverse_charge_status"]).to eq('enabled')
131+
end
132+
133+
it "can update an existing store with reverse_charge_status" do
134+
store_hash = {
135+
url: "spree123.example.com",
136+
mail_from_address: "me@example.com",
137+
bcc_email: "bcc@example.net",
138+
reverse_charge_status: "disabled"
139+
}
140+
put spree.api_store_path(store), params: { store: store_hash }
141+
expect(response.status).to eq(200)
142+
expect(store.reload.url).to eql "spree123.example.com"
143+
expect(store.reload.mail_from_address).to eql "me@example.com"
144+
expect(store.reload.bcc_email).to eql "bcc@example.net"
145+
expect(store.reload.reverse_charge_status).to eql "disabled"
146+
end
147+
end
115148
end
116149

117150
context "as an user" do

core/lib/spree/permitted_attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module PermittedAttributes
113113
@@store_attributes = [:name, :url, :seo_title, :meta_keywords,
114114
:meta_description, :default_currency,
115115
:mail_from_address, :cart_tax_country_iso,
116-
:bcc_email]
116+
:bcc_email, :reverse_charge_status]
117117

118118
@@taxonomy_attributes = [:name]
119119

0 commit comments

Comments
 (0)