solidus_core 2.3.0.rc2 → 2.3.0.rc3
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.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/models/spree/payment_method.rb +19 -0
- data/lib/spree/core/version.rb +1 -1
- data/spec/models/spree/payment_method_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89a3d4e527ba0ea59d1bdbc6b21f31cf44f28916
|
4
|
+
data.tar.gz: 44c4c11e6a69ea476145bb06910a50f1d9f3120a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 696c8894f807ec9d18cb4d979fa7094d001723c66f7f12c27635593902946c18190856b8fa0364a3c27df10dab776e0a0ac94196bc69ad4459032a3ee82c7c4c
|
7
|
+
data.tar.gz: 25de5c265c0bb56591b701d4dbf60f26ef22eb23d9d1f4bccf221f7a97dea0c7bfcb3cbc58dc98ac21e9dfa862676414d6af83f23dd10251576031129cfd9d74
|
@@ -37,6 +37,21 @@ module Spree
|
|
37
37
|
|
38
38
|
include Spree::Preferences::StaticallyConfigurable
|
39
39
|
|
40
|
+
# Custom ModelName#human implementation to ensure we don't refer to
|
41
|
+
# subclasses as just "PaymentMethod"
|
42
|
+
class ModelName < ActiveModel::Name
|
43
|
+
# Similar to ActiveModel::Name#human, but skips lookup_ancestors
|
44
|
+
def human(options = {})
|
45
|
+
defaults = [
|
46
|
+
i18n_key,
|
47
|
+
options[:default],
|
48
|
+
@human
|
49
|
+
].compact
|
50
|
+
options = { scope: [:activerecord, :models], count: 1, default: defaults }.merge!(options.except(:default))
|
51
|
+
I18n.translate(defaults.shift, options)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
40
55
|
class << self
|
41
56
|
def providers
|
42
57
|
Spree::Deprecation.warn 'Spree::PaymentMethod.providers is deprecated and will be deleted in Solidus 3.0. ' \
|
@@ -66,6 +81,10 @@ module Spree
|
|
66
81
|
end
|
67
82
|
end
|
68
83
|
|
84
|
+
def model_name
|
85
|
+
ModelName.new(self, Spree)
|
86
|
+
end
|
87
|
+
|
69
88
|
def active?
|
70
89
|
where(type: to_s, active: true).count > 0
|
71
90
|
end
|
data/lib/spree/core/version.rb
CHANGED
@@ -354,4 +354,20 @@ describe Spree::PaymentMethod, type: :model do
|
|
354
354
|
expect(payment_method.credit).to eq 'credit'
|
355
355
|
end
|
356
356
|
end
|
357
|
+
|
358
|
+
describe 'model_name.human' do
|
359
|
+
context 'PaymentMethod itself' do
|
360
|
+
it "returns i18n value" do
|
361
|
+
expect(Spree::PaymentMethod.model_name.human).to eq('Payment Method')
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
context 'A subclass with no i18n key' do
|
366
|
+
let!(:klass) { stub_const("MyGem::SomeClass", Class.new(described_class)) }
|
367
|
+
|
368
|
+
it "returns default humanized value" do
|
369
|
+
expect(klass.model_name.human).to eq('Some class')
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
357
373
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.0.
|
4
|
+
version: 2.3.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|