has_localization_table 0.3.11 → 0.3.12
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
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
MzFkNDcyZjc2NTQ0ODU3ZDFjODk1MDYwMTg3Yjk5ZGVkYmMyYWUyMg==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
NDRkNDMxYTU1NTJkNzgyMTU2OTI0Y2IxNDY0N2QwYzRmZjlmYmJiOA==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
ZTc0YTRjZmU4MDQ4ZWY5MTEwNzEwMDFmMzRlZjIyNWY3ZTQ3ZmM4ZDYzYzli
|
|
10
|
+
NDcwZTU0NTAyNDY3NWMxOTZhZjJmOTdlZTIwNTA4NmJmOTgwODBhZTc3N2Qy
|
|
11
|
+
NTdiZTc5YjVhNWU4ZWQxNGFhNGFjZmFkMmE3NDg4NDJkMDg1YzE=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
NDY1YzI2MDQ3YjgzNmQzYjlhM2JmMjA5ODYxODM4YzcxNzg3OTVlNmI3Njcw
|
|
14
|
+
MjhmMmUxOTc3MzFlZTA0NjRjYjk5NTM5YTM4OTNlNTZiNDI3YjYxOGU5ZjM5
|
|
15
|
+
NTExZWJmZmU4MThlNmZiNDE3Yzg2MDRjYjc4YTE0M2YyNjJmZGY=
|
|
@@ -7,7 +7,7 @@ module HasLocalizationTable
|
|
|
7
7
|
obj = self
|
|
8
8
|
localization_class.class_eval do
|
|
9
9
|
validates attribute, presence: { message: :custom_this_field_is_required },
|
|
10
|
-
if: proc { |model| obj.name.constantize.localized_attribute_required?(attribute) && model.send(HasLocalizationTable.locale_foreign_key) == HasLocalizationTable.
|
|
10
|
+
if: proc { |model| obj.name.constantize.localized_attribute_required?(attribute) && model.send(HasLocalizationTable.locale_foreign_key) == HasLocalizationTable.primary_locale.id }
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -35,6 +35,29 @@ describe HasLocalizationTable do
|
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
describe 'when the current locale is not the primary locale' do
|
|
39
|
+
before do
|
|
40
|
+
HasLocalizationTable.configure do |c|
|
|
41
|
+
c.current_locale = Locale.where(name: 'French').first
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
Article.has_localization_table required: true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should not be valid if only the current language is provided' do
|
|
48
|
+
a = Article.new(name: "French Name", description: "French Description")
|
|
49
|
+
refute a.valid?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'should be valid if only the primary language is provided' do
|
|
53
|
+
a = Article.new
|
|
54
|
+
s = a.localizations.detect{ |l| l.locale_id == Locale.first.id }
|
|
55
|
+
s.name = "Name"
|
|
56
|
+
s.description = "Description"
|
|
57
|
+
assert a.valid?
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
38
61
|
it "should not add validations if given required: false" do
|
|
39
62
|
Article.has_localization_table required: false
|
|
40
63
|
a = Article.new
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: has_localization_table
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Vandersluis
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
type: :runtime
|