easy_globalize3_accessors 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d0035af3caff021de85bdb173c3553565c150cad
4
+ data.tar.gz: dfe2d07945b4567081082b3c1bdaf00c80abeca4
5
+ SHA512:
6
+ metadata.gz: e8b5c21b916da59ca16a0c2fd5a43463adc08db750ca982ec5aaac954f0585dee58bf104406f5d3cbfe39804e69bd5512396b815c820db6323bc7757b95f3e43
7
+ data.tar.gz: da06fb6675fac0691f287c6a9a3e6f0891f22a714e497af591d05760d2c4fa3c9cbd293d0d67bb5a5909270d75bfaaca25e66d5fe2906624218661b79b0bfe45
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.required_rubygems_version = ">= 1.3.6"
15
15
  s.rubyforge_project = "easy_globalize3_accessors"
16
16
 
17
- s.add_dependency "globalize3", "~> 0.2.0.beta1"
17
+ s.add_dependency "globalize3", "~> 0.3.0"
18
18
 
19
19
  s.add_development_dependency "bundler", "~> 1.0.15"
20
20
  s.add_development_dependency "rake", "~> 0.9.2"
@@ -1,3 +1,3 @@
1
1
  module EasyGlobalize3Accessors
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -12,7 +12,7 @@ module EasyGlobalize3Accessors
12
12
 
13
13
 
14
14
  private
15
-
15
+
16
16
 
17
17
  def define_accessors(attr_name, locale)
18
18
  define_getter(attr_name, locale)
@@ -30,6 +30,7 @@ module EasyGlobalize3Accessors
30
30
  define_method :"#{attr_name}_#{locale}=" do |value|
31
31
  write_attribute(attr_name, value, :locale => locale)
32
32
  end
33
+ attr_accessible :"#{attr_name}_#{locale}" if accessible_attributes.include?(attr_name)
33
34
  end
34
35
 
35
36
  def each_attribute_and_locale(options)
@@ -1,18 +1,25 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class EasyGlobalizeAccessorsTest < ActiveSupport::TestCase
4
-
4
+
5
5
  class Unit < ActiveRecord::Base
6
6
  translates :name, :title
7
7
  globalize_accessors
8
8
  end
9
9
 
10
10
  class UnitTranslatedWithOptions < ActiveRecord::Base
11
- set_table_name :units
11
+ self.table_name = :units
12
12
  translates :name
13
13
  globalize_accessors :locales => [:pl], :attributes => [:name]
14
14
  end
15
15
 
16
+ class UnitWithAttrAccessible < ActiveRecord::Base
17
+ self.table_name = :units
18
+ attr_accessible :name
19
+ translates :name, :title
20
+ globalize_accessors
21
+ end
22
+
16
23
  setup do
17
24
  assert_equal :en, I18n.locale
18
25
  end
@@ -37,12 +44,12 @@ class EasyGlobalizeAccessorsTest < ActiveSupport::TestCase
37
44
 
38
45
  assert_nil u.name_pl
39
46
  assert_nil u.title_en
40
- end
47
+ end
41
48
 
42
49
  test "read on existing object" do
43
50
  u = Unit.create!(:name_en => "Name en", :title_pl => "Title pl")
44
51
  u = Unit.find(u.id)
45
-
52
+
46
53
  assert_equal "Name en", u.name
47
54
  assert_equal "Name en", u.name_en
48
55
  assert_equal "Title pl", u.title_pl
@@ -63,7 +70,7 @@ class EasyGlobalizeAccessorsTest < ActiveSupport::TestCase
63
70
  assert_equal "Name en2", u.name_en
64
71
  assert_equal "Name pl", u.name_pl
65
72
  assert_equal "Title pl", u.title_pl
66
-
73
+
67
74
  assert_nil u.title_en
68
75
  end
69
76
 
@@ -82,5 +89,15 @@ class EasyGlobalizeAccessorsTest < ActiveSupport::TestCase
82
89
  assert_equal "Name en", u.name
83
90
  assert_equal "Name pl", u.name_pl
84
91
  end
85
-
92
+
93
+ test "whitelist locale accessors if the original attribute is whitelisted" do
94
+ u = UnitWithAttrAccessible.new()
95
+ u.update_attributes(:name => "Name en", :name_pl => "Name pl", :title => "Title en", :title_pl => "Title pl")
96
+
97
+ assert_equal "Name en", u.name
98
+ assert_equal "Name pl", u.name_pl
99
+ assert_nil u.title
100
+ assert_nil u.title_pl
101
+ end
102
+
86
103
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_globalize3_accessors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
5
- prerelease:
4
+ version: 1.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tomasz Stachewicz
@@ -12,53 +11,64 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2011-10-09 00:00:00.000000000 +02:00
16
- default_executable:
14
+ date: 2013-07-22 00:00:00.000000000 Z
17
15
  dependencies:
18
16
  - !ruby/object:Gem::Dependency
19
17
  name: globalize3
20
- requirement: &72475720 !ruby/object:Gem::Requirement
21
- none: false
18
+ requirement: !ruby/object:Gem::Requirement
22
19
  requirements:
23
20
  - - ~>
24
21
  - !ruby/object:Gem::Version
25
- version: 0.2.0.beta1
22
+ version: 0.3.0
26
23
  type: :runtime
27
24
  prerelease: false
28
- version_requirements: *72475720
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.3.0
29
30
  - !ruby/object:Gem::Dependency
30
31
  name: bundler
31
- requirement: &72475120 !ruby/object:Gem::Requirement
32
- none: false
32
+ requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - ~>
35
35
  - !ruby/object:Gem::Version
36
36
  version: 1.0.15
37
37
  type: :development
38
38
  prerelease: false
39
- version_requirements: *72475120
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.15
40
44
  - !ruby/object:Gem::Dependency
41
45
  name: rake
42
- requirement: &72474410 !ruby/object:Gem::Requirement
43
- none: false
46
+ requirement: !ruby/object:Gem::Requirement
44
47
  requirements:
45
48
  - - ~>
46
49
  - !ruby/object:Gem::Version
47
50
  version: 0.9.2
48
51
  type: :development
49
52
  prerelease: false
50
- version_requirements: *72474410
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: 0.9.2
51
58
  - !ruby/object:Gem::Dependency
52
59
  name: sqlite3
53
- requirement: &72474090 !ruby/object:Gem::Requirement
54
- none: false
60
+ requirement: !ruby/object:Gem::Requirement
55
61
  requirements:
56
- - - ! '>='
62
+ - - '>='
57
63
  - !ruby/object:Gem::Version
58
64
  version: '0'
59
65
  type: :development
60
66
  prerelease: false
61
- version_requirements: *72474090
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
62
72
  description: Define methods for accessing translated attributes
63
73
  email:
64
74
  - tomekrs@o2.pl
@@ -81,32 +91,27 @@ files:
81
91
  - test/db/schema.rb
82
92
  - test/easy_globalize_accessors_test.rb
83
93
  - test/test_helper.rb
84
- has_rdoc: true
85
94
  homepage: http://rubygems.org/gems/easy_globalize3_accessors
86
95
  licenses: []
96
+ metadata: {}
87
97
  post_install_message:
88
98
  rdoc_options: []
89
99
  require_paths:
90
100
  - lib
91
101
  required_ruby_version: !ruby/object:Gem::Requirement
92
- none: false
93
102
  requirements:
94
- - - ! '>='
103
+ - - '>='
95
104
  - !ruby/object:Gem::Version
96
105
  version: '0'
97
- segments:
98
- - 0
99
- hash: -939160079
100
106
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
107
  requirements:
103
- - - ! '>='
108
+ - - '>='
104
109
  - !ruby/object:Gem::Version
105
110
  version: 1.3.6
106
111
  requirements: []
107
112
  rubyforge_project: easy_globalize3_accessors
108
- rubygems_version: 1.6.2
113
+ rubygems_version: 2.0.5
109
114
  signing_key:
110
- specification_version: 3
115
+ specification_version: 4
111
116
  summary: Define methods for accessing translated attributes
112
117
  test_files: []