ledermann-rails-settings 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e95ccf650df85deaa3086b12f49c7cf6d10cd13
4
- data.tar.gz: 4d2a68fa5cda6250f29440ec426bef760f65a72f
3
+ metadata.gz: 7ff4a6ba546d2daf89db23836a41e7a4e387afe8
4
+ data.tar.gz: 1131ffb90652265e634619fe33aa41c492d1b80b
5
5
  SHA512:
6
- metadata.gz: b6dd9ded21d964802a6a20b01b38a5d9361ce2b8d6d6ac960886504a1db17a3e562b34325351ed7c9684b33f57c872a1b48908e079d199889722401805d33135
7
- data.tar.gz: 1cdd6dbf6085d40544b52678ccaeea7cab94dbb6b907f3a10371cac806ea8263bfef230ab393da421b81692a338861dfdc1219e5c11c1fe649b9cc95f9bb52ac
6
+ metadata.gz: 5713e46631870b7f3f9e6df62893bc1ca6fa43d07f3c4f4dee3100a2c0abed752e68f21b284003a462937ba92704afd8a99651198f16b5d567cb4a8882c0a631
7
+ data.tar.gz: 8f714acf90e0db2ad9e0786f734c6d87983d4b7af8153e94b368e10185fdf18f85f7db3ccde672b454094184d96999fafebc515cde71b0237c517c7996f43857
data/Changelog.md CHANGED
@@ -1,4 +1,11 @@
1
- Version 2.0.2 (2013-03-17)
1
+ # Changelog
2
+
3
+ ## Version 2.0.3 (2013-04-16)
4
+
5
+ - Fixed bug with setting getter when settings are booleans and default is true (thanks to @mduong)
6
+
7
+
8
+ ## Version 2.0.2 (2013-03-17)
2
9
 
3
10
  - Changed database schema to allow NULL for column `value` to fix serialization
4
11
  bug with MySQL. Thanks to @steventen for pointing this out in issue #31.
@@ -7,7 +14,6 @@ Version 2.0.2 (2013-03-17)
7
14
  you use MySQL it's required to update your database schema like
8
15
  this:
9
16
 
10
- ```ruby
11
17
  class FixSettings < ActiveRecord::Migration
12
18
  def up
13
19
  change_column :settings, :value, :text, :null => true
@@ -17,15 +23,14 @@ Version 2.0.2 (2013-03-17)
17
23
  change_column :settings, :value, :text, :null => false
18
24
  end
19
25
  end
20
- ```
21
26
 
22
27
 
23
- Version 2.0.1 (2013-03-08)
28
+ ## Version 2.0.1 (2013-03-08)
24
29
 
25
30
  - Added mass assignment security by protecting all regular attributes
26
31
 
27
32
 
28
- Version 2.0.0 (2013-03-07)
33
+ ## Version 2.0.0 (2013-03-07)
29
34
 
30
35
  - Complete rewrite
31
36
  - New DSL (see README.md)
@@ -36,29 +41,29 @@ Version 2.0.0 (2013-03-07)
36
41
  - Switched to RSpec for testing
37
42
 
38
43
 
39
- Version 1.2.1 (2013-02-09)
44
+ ## Version 1.2.1 (2013-02-09)
40
45
 
41
46
  - Quick and dirty fix for design flaw in target scope implementation (thanks to Yves-Eric Martin)
42
47
  - Use Thread.current instead of cattr_accessor to be threadsafe
43
48
  - Code cleanup
44
49
 
45
50
 
46
- Version 1.2.0 (2012-07-21)
51
+ ## Version 1.2.0 (2012-07-21)
47
52
 
48
53
  - Added model-level settings (thanks to Jim Ryan)
49
54
 
50
55
 
51
- Version 1.1.0 (2012-06-01)
56
+ ## Version 1.1.0 (2012-06-01)
52
57
 
53
58
  - Added caching (thanks to Matthew McEachen)
54
59
 
55
60
 
56
- Version 1.0.1 (2011-11-05)
61
+ ## Version 1.0.1 (2011-11-05)
57
62
 
58
63
  - Gemspec: Fixed missing dependency
59
64
 
60
65
 
61
- Version 1.0.0 (2011-11-05)
66
+ ## Version 1.0.0 (2011-11-05)
62
67
 
63
68
  - Conversion from Plugin to Gem
64
69
  - Destroying false values (thanks to @Pavling)
@@ -46,7 +46,11 @@ module RailsSettings
46
46
 
47
47
  private
48
48
  def _get_value(name)
49
- value[name] || _target_class.default_settings[var.to_sym][name]
49
+ if value[name].nil?
50
+ _target_class.default_settings[var.to_sym][name]
51
+ else
52
+ value[name]
53
+ end
50
54
  end
51
55
 
52
56
  def _set_value(name, v)
@@ -1,3 +1,3 @@
1
1
  module RailsSettings
2
- VERSION = '2.0.2'
2
+ VERSION = '2.0.3'
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe RailsSettings::SettingObject do
4
4
  let(:user) { User.create! :name => 'Mr. Pink' }
5
5
  let(:new_setting_object) { user.setting_objects.build({ :var => 'dashboard'}, :without_protection => true) }
6
- let(:saved_setting_object) { user.setting_objects.create!({ :var => 'dashboard', :value => { 'theme' => 'pink', 'filter' => true}}, :without_protection => true) }
6
+ let(:saved_setting_object) { user.setting_objects.create!({ :var => 'dashboard', :value => { 'theme' => 'pink', 'filter' => false}}, :without_protection => true) }
7
7
 
8
8
  describe "serialization" do
9
9
  it "should have a hash default" do
@@ -43,7 +43,7 @@ describe RailsSettings::SettingObject do
43
43
  it "should return defaults" do
44
44
  new_setting_object.theme.should eq('blue')
45
45
  new_setting_object.view.should eq('monthly')
46
- new_setting_object.filter.should eq(false)
46
+ new_setting_object.filter.should eq(true)
47
47
  end
48
48
 
49
49
  it "should store different objects to value hash" do
@@ -86,7 +86,7 @@ describe RailsSettings::SettingObject do
86
86
 
87
87
  it "should delete key on assigning nil" do
88
88
  saved_setting_object.theme = nil
89
- saved_setting_object.value.should == { 'filter' => true }
89
+ saved_setting_object.value.should == { 'filter' => false }
90
90
  end
91
91
  end
92
92
  end
@@ -6,12 +6,12 @@ describe "Defaults" do
6
6
  end
7
7
 
8
8
  it "should be stored for parent class" do
9
- User.default_settings.should eq(:dashboard => { 'theme' => 'blue', 'view' => 'monthly', 'filter' => false },
9
+ User.default_settings.should eq(:dashboard => { 'theme' => 'blue', 'view' => 'monthly', 'filter' => true },
10
10
  :calendar => { 'scope' => 'company'})
11
11
  end
12
12
 
13
13
  it "should be stored for child class" do
14
- GuestUser.default_settings.should eq(:dashboard => { 'theme' => 'red', 'view' => 'monthly', 'filter' => false })
14
+ GuestUser.default_settings.should eq(:dashboard => { 'theme' => 'red', 'view' => 'monthly', 'filter' => true })
15
15
  end
16
16
  end
17
17
 
@@ -77,7 +77,7 @@ describe 'Objects' do
77
77
  it 'should have default settings' do
78
78
  user.settings(:dashboard).theme.should eq('blue')
79
79
  user.settings(:dashboard).view.should eq('monthly')
80
- user.settings(:dashboard).filter.should eq(false)
80
+ user.settings(:dashboard).filter.should eq(true)
81
81
  user.settings(:calendar).scope.should eq('company')
82
82
  end
83
83
 
@@ -86,20 +86,20 @@ describe 'Objects' do
86
86
 
87
87
  user.settings(:dashboard).theme.should eq('gray')
88
88
  user.settings(:dashboard).view.should eq('monthly')
89
- user.settings(:dashboard).filter.should eq(false)
89
+ user.settings(:dashboard).filter.should eq(true)
90
90
  user.settings(:calendar).scope.should eq('company')
91
91
  end
92
92
 
93
93
  it "should overwrite settings" do
94
94
  user.settings(:dashboard).theme = 'brown'
95
- user.settings(:dashboard).filter = true
95
+ user.settings(:dashboard).filter = false
96
96
  user.save!
97
97
 
98
98
  user.reload
99
99
  user.settings(:dashboard).theme.should eq('brown')
100
- user.settings(:dashboard).filter.should eq(true)
100
+ user.settings(:dashboard).filter.should eq(false)
101
101
  RailsSettings::SettingObject.count.should eq(1)
102
- RailsSettings::SettingObject.first.value.should == { 'theme' => 'brown', 'filter' => true }
102
+ RailsSettings::SettingObject.first.value.should == { 'theme' => 'brown', 'filter' => false }
103
103
  end
104
104
 
105
105
  it "should merge settings with defaults" do
@@ -108,7 +108,7 @@ describe 'Objects' do
108
108
 
109
109
  user.reload
110
110
  user.settings(:dashboard).theme.should eq('brown')
111
- user.settings(:dashboard).filter.should eq(false)
111
+ user.settings(:dashboard).filter.should eq(true)
112
112
  RailsSettings::SettingObject.count.should eq(1)
113
113
  RailsSettings::SettingObject.first.value.should == { 'theme' => 'brown' }
114
114
  end
data/spec/spec_helper.rb CHANGED
@@ -25,14 +25,14 @@ require 'rails-settings'
25
25
 
26
26
  class User < ActiveRecord::Base
27
27
  has_settings do |s|
28
- s.key :dashboard, :defaults => { :theme => 'blue', :view => 'monthly', :filter => false }
28
+ s.key :dashboard, :defaults => { :theme => 'blue', :view => 'monthly', :filter => true }
29
29
  s.key :calendar, :defaults => { :scope => 'company'}
30
30
  end
31
31
  end
32
32
 
33
33
  class GuestUser < User
34
34
  has_settings do |s|
35
- s.key :dashboard, :defaults => { :theme => 'red', :view => 'monthly', :filter => false }
35
+ s.key :dashboard, :defaults => { :theme => 'red', :view => 'monthly', :filter => true }
36
36
  end
37
37
  end
38
38
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ledermann-rails-settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Ledermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-17 00:00:00.000000000 Z
11
+ date: 2013-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord