solidus_core_devise_token_auth 2.8.0.alpha.1 → 2.8.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Spree
4
4
  def self.solidus_version
5
- "2.8.0.alpha.1"
5
+ "2.8.0.alpha.3"
6
6
  end
7
7
 
8
8
  def self.solidus_gem_version
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 html: true as well.
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 as html.
84
- def to_html(options = { html: true })
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
- if options[:html]
87
- # 1) prevent blank, breaking spaces
88
- # 2) prevent escaping of HTML character entities
89
- output = output.sub(" ", "&nbsp;").html_safe
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 stub_authorization!
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
- before do
44
- allow(Spree.user_class).to receive(:find_by).
45
- and_return(create(:user))
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
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'spree/core'
4
+ require 'devise_token_auth'
@@ -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: $5.00)") }
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: $5.00)") }
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: &#x00A5;50)") }
59
+ it { is_expected.to eq("(Add: <span class=\"money-currency-symbol\">&#x00A5;</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: &#x00A5;50)") }
65
+ it { is_expected.to eq("(Subtract: <span class=\"money-currency-symbol\">&#x00A5;</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("$15.00")
83
- expect(helper.variant_price(variant_2)).to eq("$20.00")
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("&#x00A5;150")
98
+ expect(helper.variant_price(variant)).to eq("<span class=\"money-currency-symbol\">&#x00A5;</span><span class=\"money-whole\">150</span>")
99
99
  end
100
100
  end
101
101
 
@@ -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
- context "user's email is blank" do
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
- let(:factory) { :admin_user }
16
+ it "builds successfully" do
17
+ expect(build(:user, :admin)).to be_a(factory_class)
18
+ end
16
19
 
17
- it_behaves_like 'a working factory'
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
- let(:factory) { :user_with_addresses }
30
+ it "builds successfully" do
31
+ expect(build(:user, :with_addresses)).to be_a(factory_class)
32
+ end
21
33
 
22
- it_behaves_like 'a working factory'
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 'spec_helper'
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, html: false)
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, html: false)
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', html: false)
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, symbol_position: :after, html: false)
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, symbol_position: :after, html: false)
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, html: false)
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, symbol_position: :after)
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, symbol_position: :after)
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.00&nbsp;&#x20AC;")
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\">&#x20AC;</span>")
187
186
  end
188
187
 
189
188
  it "formats as HTML with currency" do
190
- money = Spree::Money.new(10, symbol_position: :after, with_currency: true)
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.00&nbsp;&#x20AC; <span class=\"currency\">EUR</span>")
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\">&#x20AC;</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) { build(:user) }
27
+ let(:user) { create(:user) }
28
28
  let(:ability) { Spree::Ability.new(user) }
29
- let(:token) { nil }
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) { build :admin_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 :admin_user }
94
- let(:order) { create :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.1
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-23 00:00:00.000000000 Z
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