has_settings 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/has_settings.gemspec +1 -1
- data/lib/has_settings/active_record_extension.rb +1 -1
- data/lib/has_settings/setting.rb +1 -1
- data/test/test_has_settings.rb +15 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/has_settings.gemspec
CHANGED
data/lib/has_settings/setting.rb
CHANGED
@@ -51,7 +51,7 @@ module HasSettings
|
|
51
51
|
@owner_class_sym = owner_class.name.underscore.to_sym
|
52
52
|
belongs_to owner_class_sym
|
53
53
|
validates_presence_of owner_class_sym
|
54
|
-
validates_uniqueness_of :
|
54
|
+
validates_uniqueness_of :name, :scope => owner_class_key_sym
|
55
55
|
|
56
56
|
if owner_class.table_exists? && owner_class.column_names.include?('updated_at')
|
57
57
|
before_create :update_owner_timestamp
|
data/test/test_has_settings.rb
CHANGED
@@ -69,5 +69,20 @@ class TestHasSettings < ActiveSupport::TestCase
|
|
69
69
|
assert !a.settings.archive?
|
70
70
|
assert a.settings.ssl?
|
71
71
|
end
|
72
|
+
|
73
|
+
should "be able to build multiple settings in one go" do
|
74
|
+
a = Account.create(:name => 'name')
|
75
|
+
assert a.settings.empty?
|
76
|
+
a.settings.build('archive', 'ssl')
|
77
|
+
assert a.settings.size == 2
|
78
|
+
end
|
79
|
+
|
80
|
+
should "validate uniqueness of settings" do
|
81
|
+
a = Account.create(:name => 'name')
|
82
|
+
AccountSetting.create!(:account => a, :name => 'fish')
|
83
|
+
assert_raise ActiveRecord::RecordInvalid do
|
84
|
+
AccountSetting.create!(:account => a, :name => 'fish')
|
85
|
+
end
|
86
|
+
end
|
72
87
|
end
|
73
88
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morten Primdahl
|