solidus_core_devise_token_auth 2.8.0.alpha.1 → 2.8.0.alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/initializers/money.rb +5 -0
- data/config/locales/en.yml +3 -0
- data/db/migrate/20160101010000_solidus_one_four.rb +1096 -1082
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/i18n.rb +4 -0
- data/lib/spree/money.rb +13 -11
- data/lib/spree/testing_support/authorization_helpers.rb +13 -7
- data/lib/spree_core.rb +1 -0
- data/spec/helpers/products_helper_spec.rb +7 -7
- data/spec/lib/i18n_spec.rb +5 -0
- data/spec/lib/spree/core/controller_helpers/order_spec.rb +2 -1
- data/spec/lib/spree/core/testing_support/factories/user_factory_spec.rb +22 -4
- data/spec/lib/spree/money_spec.rb +12 -13
- data/spec/models/spree/ability_spec.rb +3 -3
- data/spec/models/spree/order_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/user_spec.rb +2 -2
- metadata +3 -2
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/i18n.rb
CHANGED
@@ -26,6 +26,10 @@ module Spree
|
|
26
26
|
# extra functionality. e.g return reasonable strings for missing translations
|
27
27
|
|
28
28
|
def translate(key, options = {})
|
29
|
+
Spree::Deprecation.warn <<-WARN.squish
|
30
|
+
Spree.t & Spree.translate have been deprecated.
|
31
|
+
Instead use I18n.t('spree.your_translation_key')
|
32
|
+
WARN
|
29
33
|
options[:scope] = [:spree, *options[:scope]]
|
30
34
|
TranslationHelperWrapper.new.translate(key, options)
|
31
35
|
end
|
data/lib/spree/money.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'money'
|
4
|
-
require 'monetize'
|
5
|
-
require 'active_support/core_ext/string/output_safety'
|
6
|
-
|
7
3
|
module Spree
|
8
4
|
# Spree::Money is a relatively thin wrapper around Monetize which handles
|
9
5
|
# formatting via Spree::Config.
|
@@ -77,16 +73,22 @@ module Spree
|
|
77
73
|
@money.format(@options.merge(options))
|
78
74
|
end
|
79
75
|
|
80
|
-
# @note If you pass in options, ensure you pass in the
|
76
|
+
# @note If you pass in options, ensure you pass in the { html_wrap: true } as well.
|
81
77
|
# @param options [Hash] additional formatting options
|
82
78
|
# @return [String] the value of this money object formatted according to
|
83
|
-
# its options and any additional options, by default
|
84
|
-
def to_html(options = {
|
79
|
+
# its options and any additional options, by default with html_wrap.
|
80
|
+
def to_html(options = { html_wrap: true })
|
85
81
|
output = format(options)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
82
|
+
# Maintain compatibility by checking html option renamed to html_wrap.
|
83
|
+
if options[:html] || options[:html] == false
|
84
|
+
Spree::Deprecation.warn <<-WARN.squish, caller
|
85
|
+
Spree::Money#to_html called with Spree::Money#to_html(html: #{options[:html]}),
|
86
|
+
which will not be supported in the future.
|
87
|
+
Instead use :html_wrap e.g. Spree::Money#to_html(html_wrap: #{options[:html]})
|
88
|
+
WARN
|
89
|
+
end
|
90
|
+
if options[:html_wrap] || options[:html]
|
91
|
+
output = output.html_safe
|
90
92
|
end
|
91
93
|
output
|
92
94
|
end
|
@@ -29,7 +29,15 @@ module Spree
|
|
29
29
|
module Request
|
30
30
|
include CustomAbility
|
31
31
|
|
32
|
-
def
|
32
|
+
def stub_api_authentication!
|
33
|
+
before do
|
34
|
+
allow_any_instance_of(Spree::Api::BaseController)
|
35
|
+
.to receive("current_api_#{Spree.user_class.to_s.underscore.gsub('/', '_')}")
|
36
|
+
.and_return(create(:user))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def stub_ability_authorization!
|
33
41
|
ability = build_ability
|
34
42
|
|
35
43
|
after(:all) do
|
@@ -39,13 +47,11 @@ module Spree
|
|
39
47
|
before(:all) do
|
40
48
|
Spree::Ability.register_ability(ability)
|
41
49
|
end
|
50
|
+
end
|
42
51
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
allow_any_instance_of(Spree.user_class).to receive(:valid_token?).
|
47
|
-
and_return(true)
|
48
|
-
end
|
52
|
+
def stub_authorization!
|
53
|
+
stub_ability_authorization!
|
54
|
+
stub_api_authentication!
|
49
55
|
end
|
50
56
|
|
51
57
|
def custom_authorization!(&block)
|
data/lib/spree_core.rb
CHANGED
@@ -31,7 +31,7 @@ module Spree
|
|
31
31
|
context "when variant is more than master" do
|
32
32
|
let(:variant_price) { 15 }
|
33
33
|
|
34
|
-
it { is_expected.to eq("(Add:
|
34
|
+
it { is_expected.to eq("(Add: <span class=\"money-currency-symbol\">$</span><span class=\"money-whole\">5</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">00</span>)") }
|
35
35
|
# Regression test for https://github.com/spree/spree/issues/2737
|
36
36
|
it { is_expected.to be_html_safe }
|
37
37
|
end
|
@@ -39,7 +39,7 @@ module Spree
|
|
39
39
|
context "when variant is less than master" do
|
40
40
|
let(:product_price) { 15 }
|
41
41
|
|
42
|
-
it { is_expected.to eq("(Subtract:
|
42
|
+
it { is_expected.to eq("(Subtract: <span class=\"money-currency-symbol\">$</span><span class=\"money-whole\">5</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">00</span>)") }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -56,13 +56,13 @@ module Spree
|
|
56
56
|
context "when variant is more than master" do
|
57
57
|
let(:variant_price) { 150 }
|
58
58
|
|
59
|
-
it { is_expected.to eq("(Add:
|
59
|
+
it { is_expected.to eq("(Add: <span class=\"money-currency-symbol\">¥</span><span class=\"money-whole\">50</span>)") }
|
60
60
|
end
|
61
61
|
|
62
62
|
context "when variant is less than master" do
|
63
63
|
let(:product_price) { 150 }
|
64
64
|
|
65
|
-
it { is_expected.to eq("(Subtract:
|
65
|
+
it { is_expected.to eq("(Subtract: <span class=\"money-currency-symbol\">¥</span><span class=\"money-whole\">50</span>)") }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -79,8 +79,8 @@ module Spree
|
|
79
79
|
|
80
80
|
context "when currency is default" do
|
81
81
|
it "should return the variant price if the price is different than master" do
|
82
|
-
expect(helper.variant_price(variant)).to eq("
|
83
|
-
expect(helper.variant_price(variant_2)).to eq("
|
82
|
+
expect(helper.variant_price(variant)).to eq("<span class=\"money-currency-symbol\">$</span><span class=\"money-whole\">15</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">00</span>")
|
83
|
+
expect(helper.variant_price(variant_2)).to eq("<span class=\"money-currency-symbol\">$</span><span class=\"money-whole\">20</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">00</span>")
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -95,7 +95,7 @@ module Spree
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should return the variant price if the price is different than master" do
|
98
|
-
expect(helper.variant_price(variant)).to eq("
|
98
|
+
expect(helper.variant_price(variant)).to eq("<span class=\"money-currency-symbol\">¥</span><span class=\"money-whole\">150</span>")
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
data/spec/lib/i18n_spec.rb
CHANGED
@@ -30,23 +30,28 @@ RSpec.describe "i18n" do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "translates within the spree scope" do
|
33
|
+
expect(Spree::Deprecation).to receive(:warn).twice
|
33
34
|
expect(Spree.t(:foo)).to eql("bar")
|
34
35
|
expect(Spree.translate(:foo)).to eql("bar")
|
35
36
|
end
|
36
37
|
|
37
38
|
it "prepends a string scope" do
|
39
|
+
expect(Spree::Deprecation).to receive(:warn)
|
38
40
|
expect(Spree.t(:foo, scope: "bar")).to eql("bar within bar scope")
|
39
41
|
end
|
40
42
|
|
41
43
|
it "prepends to an array scope" do
|
44
|
+
expect(Spree::Deprecation).to receive(:warn)
|
42
45
|
expect(Spree.t(:foo, scope: ["bar"])).to eql("bar within bar scope")
|
43
46
|
end
|
44
47
|
|
45
48
|
it "returns two translations" do
|
49
|
+
expect(Spree::Deprecation).to receive(:warn)
|
46
50
|
expect(Spree.t([:foo, 'bar.foo'])).to eql(["bar", "bar within bar scope"])
|
47
51
|
end
|
48
52
|
|
49
53
|
it "returns reasonable string for missing translations" do
|
54
|
+
expect(Spree::Deprecation).to receive(:warn)
|
50
55
|
expect(Spree.t(:missing_entry)).to include("<span")
|
51
56
|
end
|
52
57
|
|
@@ -78,7 +78,8 @@ RSpec.describe Spree::Core::ControllerHelpers::Order, type: :controller do
|
|
78
78
|
|
79
79
|
describe '#associate_user' do
|
80
80
|
before { allow(controller).to receive_messages(current_order: order) }
|
81
|
-
|
81
|
+
# we can't create user without an email when we use devise
|
82
|
+
xcontext "user's email is blank" do
|
82
83
|
let(:user) { create(:user, email: '') }
|
83
84
|
it 'calls Spree::Order#associate_user! method' do
|
84
85
|
expect_any_instance_of(Spree::Order).to receive(:associate_user!)
|
@@ -11,14 +11,32 @@ RSpec.describe 'user factory' do
|
|
11
11
|
|
12
12
|
it_behaves_like 'a working factory'
|
13
13
|
end
|
14
|
+
|
14
15
|
describe 'admin user' do
|
15
|
-
|
16
|
+
it "builds successfully" do
|
17
|
+
expect(build(:user, :admin)).to be_a(factory_class)
|
18
|
+
end
|
16
19
|
|
17
|
-
|
20
|
+
it "creates successfully" do
|
21
|
+
expect(build(:user, :admin)).to be_a(factory_class)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "is creates a valid record" do
|
25
|
+
expect(build(:user, :admin)).to be_valid
|
26
|
+
end
|
18
27
|
end
|
28
|
+
|
19
29
|
describe 'user with addresses' do
|
20
|
-
|
30
|
+
it "builds successfully" do
|
31
|
+
expect(build(:user, :with_addresses)).to be_a(factory_class)
|
32
|
+
end
|
21
33
|
|
22
|
-
|
34
|
+
it "creates successfully" do
|
35
|
+
expect(build(:user, :with_addresses)).to be_a(factory_class)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "is creates a valid record" do
|
39
|
+
expect(build(:user, :with_addresses)).to be_valid
|
40
|
+
end
|
23
41
|
end
|
24
42
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'spree/money'
|
3
|
+
require 'rails_helper'
|
5
4
|
|
6
5
|
RSpec.describe Spree::Money do
|
7
6
|
before do
|
@@ -97,7 +96,7 @@ RSpec.describe Spree::Money do
|
|
97
96
|
|
98
97
|
context "with currency" do
|
99
98
|
it "passed in option" do
|
100
|
-
money = Spree::Money.new(10, with_currency: true,
|
99
|
+
money = Spree::Money.new(10, with_currency: true, html_wrap: false)
|
101
100
|
expect(money.to_s).to eq("$10.00 USD")
|
102
101
|
end
|
103
102
|
end
|
@@ -117,14 +116,14 @@ RSpec.describe Spree::Money do
|
|
117
116
|
context "currency parameter" do
|
118
117
|
context "when currency is specified in Canadian Dollars" do
|
119
118
|
it "uses the currency param over the global configuration" do
|
120
|
-
money = Spree::Money.new(10, currency: 'CAD', with_currency: true,
|
119
|
+
money = Spree::Money.new(10, currency: 'CAD', with_currency: true, html_wrap: false)
|
121
120
|
expect(money.to_s).to eq("$10.00 CAD")
|
122
121
|
end
|
123
122
|
end
|
124
123
|
|
125
124
|
context "when currency is specified in Japanese Yen" do
|
126
125
|
it "uses the currency param over the global configuration" do
|
127
|
-
money = Spree::Money.new(100, currency: 'JPY',
|
126
|
+
money = Spree::Money.new(100, currency: 'JPY', html_wrap: false)
|
128
127
|
expect(money.to_s).to eq("¥100")
|
129
128
|
end
|
130
129
|
end
|
@@ -132,12 +131,12 @@ RSpec.describe Spree::Money do
|
|
132
131
|
|
133
132
|
context "symbol positioning" do
|
134
133
|
it "passed in option" do
|
135
|
-
money = Spree::Money.new(10,
|
134
|
+
money = Spree::Money.new(10, format: '%n %u', html_wrap: false)
|
136
135
|
expect(money.to_s).to eq("10.00 $")
|
137
136
|
end
|
138
137
|
|
139
138
|
it "config option" do
|
140
|
-
money = Spree::Money.new(10,
|
139
|
+
money = Spree::Money.new(10, format: '%n %u', html_wrap: false)
|
141
140
|
expect(money.to_s).to eq("10.00 $")
|
142
141
|
end
|
143
142
|
end
|
@@ -162,7 +161,7 @@ RSpec.describe Spree::Money do
|
|
162
161
|
end
|
163
162
|
|
164
163
|
it "formats correctly" do
|
165
|
-
money = Spree::Money.new(1000,
|
164
|
+
money = Spree::Money.new(1000, html_wrap: false)
|
166
165
|
expect(money.to_s).to eq("¥1,000")
|
167
166
|
end
|
168
167
|
end
|
@@ -176,20 +175,20 @@ RSpec.describe Spree::Money do
|
|
176
175
|
|
177
176
|
# Regression test for https://github.com/spree/spree/issues/2634
|
178
177
|
it "formats as plain by default" do
|
179
|
-
money = Spree::Money.new(10,
|
178
|
+
money = Spree::Money.new(10, format: '%n %u')
|
180
179
|
expect(money.to_s).to eq("10.00 €")
|
181
180
|
end
|
182
181
|
|
183
182
|
it "formats as HTML if asked (nicely) to" do
|
184
|
-
money = Spree::Money.new(10,
|
183
|
+
money = Spree::Money.new(10, format: '%n %u')
|
185
184
|
# The HTML'ified version of "10.00 €"
|
186
|
-
expect(money.to_html).to eq("10
|
185
|
+
expect(money.to_html).to eq("<span class=\"money-whole\">10</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">00</span> <span class=\"money-currency-symbol\">€</span>")
|
187
186
|
end
|
188
187
|
|
189
188
|
it "formats as HTML with currency" do
|
190
|
-
money = Spree::Money.new(10,
|
189
|
+
money = Spree::Money.new(10, format: '%n %u', with_currency: true)
|
191
190
|
# The HTML'ified version of "10.00 €"
|
192
|
-
expect(money.to_html).to eq("10
|
191
|
+
expect(money.to_html).to eq("<span class=\"money-whole\">10</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">00</span> <span class=\"money-currency-symbol\">€</span> <span class=\"money-currency\">EUR</span>")
|
193
192
|
end
|
194
193
|
end
|
195
194
|
|
@@ -24,9 +24,9 @@ class FooAbility
|
|
24
24
|
end
|
25
25
|
|
26
26
|
RSpec.describe Spree::Ability, type: :model do
|
27
|
-
let(:user)
|
27
|
+
let(:user) { create(:user) }
|
28
28
|
let(:ability) { Spree::Ability.new(user) }
|
29
|
-
let(:token)
|
29
|
+
let(:token) { nil }
|
30
30
|
|
31
31
|
after(:each) {
|
32
32
|
Spree::Ability.abilities = Set.new
|
@@ -59,7 +59,7 @@ RSpec.describe Spree::Ability, type: :model do
|
|
59
59
|
let(:resource) { Object.new }
|
60
60
|
|
61
61
|
context 'with admin user' do
|
62
|
-
let(:user) {
|
62
|
+
let(:user) { create(:user, :admin) }
|
63
63
|
it_should_behave_like 'access granted'
|
64
64
|
it_should_behave_like 'index allowed'
|
65
65
|
end
|
@@ -90,8 +90,8 @@ RSpec.describe Spree::Order, type: :model do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
context "#canceled_by" do
|
93
|
-
let(:admin_user) { create :
|
94
|
-
let(:order)
|
93
|
+
let(:admin_user) { create :user, :admin }
|
94
|
+
let(:order) { create :order }
|
95
95
|
|
96
96
|
before do
|
97
97
|
allow(order).to receive(:cancel!)
|
@@ -31,8 +31,8 @@ RSpec.describe Spree::Promotion::Rules::User, type: :model do
|
|
31
31
|
|
32
32
|
# Regression test for https://github.com/spree/spree/issues/3885
|
33
33
|
it "can assign to user_ids" do
|
34
|
-
user1 = Spree::LegacyUser.create!(email: "test1@example.com")
|
35
|
-
user2 = Spree::LegacyUser.create!(email: "test2@example.com")
|
34
|
+
user1 = Spree::LegacyUser.create!(email: "test1@example.com", password: 'lubieplacki')
|
35
|
+
user2 = Spree::LegacyUser.create!(email: "test2@example.com", password: 'lubieplacki')
|
36
36
|
rule.user_ids = "#{user1.id}, #{user2.id}"
|
37
37
|
end
|
38
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_core_devise_token_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.0.alpha.
|
4
|
+
version: 2.8.0.alpha.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Siwek (skycocker)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -662,6 +662,7 @@ files:
|
|
662
662
|
- app/views/spree/test_mailer/test_email.text.erb
|
663
663
|
- config/initializers/assets.rb
|
664
664
|
- config/initializers/friendly_id.rb
|
665
|
+
- config/initializers/money.rb
|
665
666
|
- config/locales/en.yml
|
666
667
|
- db/default/spree/countries.rb
|
667
668
|
- db/default/spree/refund_reasons.rb
|