cockpit 0.0.1.7 → 0.1.1
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.
- data/README.markdown +100 -199
- data/Rakefile +5 -4
- data/lib/cockpit/core/definition.rb +93 -0
- data/lib/cockpit/core/definitions.rb +55 -0
- data/lib/cockpit/core/include.rb +90 -0
- data/lib/cockpit/core/settings.rb +148 -0
- data/lib/cockpit/core/store.rb +51 -0
- data/lib/cockpit/many/include.rb +18 -0
- data/lib/cockpit/many/settings.rb +21 -0
- data/lib/cockpit/moneta/active_record.rb +120 -0
- data/lib/cockpit/moneta/simple_active_record.rb +93 -0
- data/lib/cockpit.rb +4 -10
- data/test/lib/database.rb +1 -2
- data/test/lib/user.rb +5 -3
- data/test/test_active_record.rb +80 -0
- data/test/test_helper.rb +5 -7
- data/test/test_mongo.rb +82 -0
- data/test/test_stores.rb +125 -0
- metadata +33 -22
- data/app/models/setting.rb +0 -59
- data/init.rb +0 -1
- data/lib/cockpit/cockpit.rb +0 -101
- data/lib/cockpit/configuration.rb +0 -218
- data/lib/cockpit/definition.rb +0 -55
- data/lib/cockpit/extensions.rb +0 -25
- data/lib/cockpit/helper.rb +0 -44
- data/lib/cockpit/store.rb +0 -103
- data/lib/cockpit/tree_hash.rb +0 -116
- data/rails/init.rb +0 -1
- data/test/test_settings.rb +0 -228
- data/test/test_settings_in_database.rb +0 -153
- data/test/test_settings_on_model.rb +0 -68
@@ -1,68 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
-
|
3
|
-
class SettingsTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
context "Settings" do
|
6
|
-
context "acts_as_configurable module" do
|
7
|
-
|
8
|
-
setup do
|
9
|
-
@user = User.new
|
10
|
-
end
|
11
|
-
|
12
|
-
should "have added settings to global hash" do
|
13
|
-
assert User.settings
|
14
|
-
assert_equal "Lance", @user.settings.name.value
|
15
|
-
assert_equal({:type => :string, :value => "red"}, @user.settings.favorite.color)
|
16
|
-
end
|
17
|
-
|
18
|
-
should "be able to set value" do
|
19
|
-
Settings.user.login = "LOGIN"
|
20
|
-
assert_equal({:type=>:string, :value => "LOGIN"}, Settings.user.login)
|
21
|
-
assert_equal "LOGIN", Settings.user.login.value
|
22
|
-
end
|
23
|
-
|
24
|
-
context "multiple users, custom settings" do
|
25
|
-
|
26
|
-
setup do
|
27
|
-
Settings.clear(:except => [:user])
|
28
|
-
@user_a = User.create
|
29
|
-
@user_b = User.create
|
30
|
-
@now = Time.now
|
31
|
-
end
|
32
|
-
|
33
|
-
should "be able to change settings for user instances" do
|
34
|
-
@user_a.settings[:im_a] = "yes"
|
35
|
-
@user_b.settings[:im_b] = "yippee"
|
36
|
-
assert_equal "yes", @user_a.settings(:im_a).value
|
37
|
-
assert_equal "yippee", @user_b.settings.im_b.value
|
38
|
-
assert_not_equal @user_a.settings, Settings(:user)
|
39
|
-
assert_not_equal "yes", Settings(:user).im_a.value # global settings not changed
|
40
|
-
end
|
41
|
-
|
42
|
-
should "be able to save the user" do
|
43
|
-
@user_a.settings.store = :db
|
44
|
-
@user_a.settings["im_a.having.fun"] = "lance"
|
45
|
-
@user_a.settings["im_a.having.a.good.time"] = @now
|
46
|
-
assert @user_a.valid?
|
47
|
-
assert_equal "lance", Setting.find_by_key("im_a.having.fun").value
|
48
|
-
assert_equal @user_a, Setting.find_by_key("im_a.having.fun").configurable
|
49
|
-
assert_equal @user_a, Setting.find_by_key("im_a.having.a.good.time").configurable
|
50
|
-
assert_equal @now.to_s, Setting.find_by_key("im_a.having.a.good.time").value.to_s
|
51
|
-
# global settings should be unchanged
|
52
|
-
assert_kind_of Cockpit::Store::Database, @user_a.settings.store
|
53
|
-
#assert_kind_of Cockpit::Store::Memory, Settings.store
|
54
|
-
end
|
55
|
-
|
56
|
-
teardown do
|
57
|
-
@user_a.settings.store = :memory
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
teardown { Settings.clear(:except => [:user]) }
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|