netzke-core 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +19 -0
- data/CHANGELOG.rdoc +3 -0
- data/README.md +17 -9
- data/Rakefile +6 -2
- data/config/ci/before-travis.sh +11 -0
- data/lib/netzke/actions.rb +5 -8
- data/lib/netzke/base.rb +0 -4
- data/lib/netzke/composition.rb +92 -99
- data/lib/netzke/config_to_dsl_delegator.rb +12 -10
- data/lib/netzke/configuration.rb +82 -80
- data/lib/netzke/core/version.rb +1 -1
- data/lib/netzke/core_ext/symbol.rb +4 -0
- data/lib/netzke/core_ext.rb +2 -1
- data/lib/netzke/inheritance.rb +10 -10
- data/lib/netzke/javascript.rb +92 -79
- data/lib/netzke/plugins.rb +7 -7
- data/lib/netzke/services.rb +7 -8
- data/lib/netzke/stylesheets.rb +6 -8
- data/netzke-core.gemspec +8 -5
- data/test/core_test_app/.powrc +4 -0
- data/test/core_test_app/.rvmrc +1 -1
- data/test/core_test_app/Gemfile +4 -3
- data/test/core_test_app/Gemfile.lock +88 -89
- data/test/core_test_app/config/database.yml.travis +13 -0
- data/test/core_test_app/gemfiles/rails3_1.gemfile +16 -0
- data/test/core_test_app/gemfiles/rails3_2.gemfile +16 -0
- data/test/core_test_app/spec/component/composition_spec.rb +10 -10
- data/test/test_helper.rb +3 -21
- data/test/unit/core_ext_test.rb +1 -13
- data/test/unit/netzke_core_test.rb +1 -1
- metadata +10 -7
- data/test/fixtures/roles.yml +0 -7
- data/test/fixtures/users.yml +0 -9
- data/test/unit/netzke_preference_test.rb +0 -103
@@ -1,138 +1,136 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionmailer (3.
|
5
|
-
actionpack (= 3.
|
6
|
-
mail (~> 2.
|
7
|
-
actionpack (3.
|
8
|
-
activemodel (= 3.
|
9
|
-
activesupport (= 3.
|
4
|
+
actionmailer (3.2.3)
|
5
|
+
actionpack (= 3.2.3)
|
6
|
+
mail (~> 2.4.4)
|
7
|
+
actionpack (3.2.3)
|
8
|
+
activemodel (= 3.2.3)
|
9
|
+
activesupport (= 3.2.3)
|
10
10
|
builder (~> 3.0.0)
|
11
11
|
erubis (~> 2.7.0)
|
12
|
-
|
13
|
-
rack (~> 1.
|
14
|
-
rack-cache (~> 1.
|
15
|
-
rack-mount (~> 0.8.2)
|
12
|
+
journey (~> 1.0.1)
|
13
|
+
rack (~> 1.4.0)
|
14
|
+
rack-cache (~> 1.2)
|
16
15
|
rack-test (~> 0.6.1)
|
17
|
-
sprockets (~> 2.
|
18
|
-
activemodel (3.
|
19
|
-
activesupport (= 3.
|
20
|
-
bcrypt-ruby (~> 3.0.0)
|
16
|
+
sprockets (~> 2.1.2)
|
17
|
+
activemodel (3.2.3)
|
18
|
+
activesupport (= 3.2.3)
|
21
19
|
builder (~> 3.0.0)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
arel (~> 2.2.1)
|
20
|
+
activerecord (3.2.3)
|
21
|
+
activemodel (= 3.2.3)
|
22
|
+
activesupport (= 3.2.3)
|
23
|
+
arel (~> 3.0.2)
|
27
24
|
tzinfo (~> 0.3.29)
|
28
|
-
activeresource (3.
|
29
|
-
activemodel (= 3.
|
30
|
-
activesupport (= 3.
|
31
|
-
activesupport (3.
|
25
|
+
activeresource (3.2.3)
|
26
|
+
activemodel (= 3.2.3)
|
27
|
+
activesupport (= 3.2.3)
|
28
|
+
activesupport (3.2.3)
|
29
|
+
i18n (~> 0.6)
|
32
30
|
multi_json (~> 1.0)
|
33
|
-
addressable (2.2.
|
34
|
-
arel (
|
35
|
-
bcrypt-ruby (3.0.0)
|
31
|
+
addressable (2.2.7)
|
32
|
+
arel (3.0.2)
|
36
33
|
builder (3.0.0)
|
37
|
-
capybara (1.1.
|
34
|
+
capybara (1.1.2)
|
38
35
|
mime-types (>= 1.16)
|
39
36
|
nokogiri (>= 1.3.3)
|
40
37
|
rack (>= 1.0.0)
|
41
38
|
rack-test (>= 0.5.4)
|
42
39
|
selenium-webdriver (~> 2.0)
|
43
40
|
xpath (~> 0.1.4)
|
44
|
-
childprocess (0.
|
41
|
+
childprocess (0.3.1)
|
45
42
|
ffi (~> 1.0.6)
|
46
|
-
cucumber (1.
|
43
|
+
cucumber (1.1.9)
|
47
44
|
builder (>= 2.1.2)
|
48
45
|
diff-lcs (>= 1.1.2)
|
49
|
-
gherkin (~> 2.
|
46
|
+
gherkin (~> 2.9.0)
|
50
47
|
json (>= 1.4.6)
|
51
|
-
term-ansicolor (>= 1.0.
|
52
|
-
cucumber-rails (1.0
|
53
|
-
capybara (>= 1.
|
54
|
-
cucumber (
|
55
|
-
nokogiri (>= 1.
|
56
|
-
database_cleaner (0.
|
48
|
+
term-ansicolor (>= 1.0.6)
|
49
|
+
cucumber-rails (1.3.0)
|
50
|
+
capybara (>= 1.1.2)
|
51
|
+
cucumber (>= 1.1.8)
|
52
|
+
nokogiri (>= 1.5.0)
|
53
|
+
database_cleaner (0.7.2)
|
57
54
|
diff-lcs (1.1.3)
|
58
55
|
erubis (2.7.0)
|
59
|
-
ffi (1.0.
|
60
|
-
gherkin (2.
|
56
|
+
ffi (1.0.11)
|
57
|
+
gherkin (2.9.3)
|
61
58
|
json (>= 1.4.6)
|
62
59
|
hike (1.2.1)
|
63
60
|
i18n (0.6.0)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
launchy (2.0.5)
|
61
|
+
journey (1.0.3)
|
62
|
+
json (1.6.6)
|
63
|
+
launchy (2.1.0)
|
68
64
|
addressable (~> 2.2.6)
|
69
|
-
|
65
|
+
libwebsocket (0.1.3)
|
66
|
+
addressable
|
67
|
+
mail (2.4.4)
|
70
68
|
i18n (>= 0.4.0)
|
71
69
|
mime-types (~> 1.16)
|
72
70
|
treetop (~> 1.4.8)
|
73
|
-
mime-types (1.
|
74
|
-
multi_json (1.
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
rack
|
71
|
+
mime-types (1.18)
|
72
|
+
multi_json (1.3.2)
|
73
|
+
netzke-persistence (0.1.0)
|
74
|
+
nokogiri (1.5.2)
|
75
|
+
polyglot (0.3.3)
|
76
|
+
rack (1.4.1)
|
77
|
+
rack-cache (1.2)
|
79
78
|
rack (>= 0.4)
|
80
|
-
rack-mount (0.8.3)
|
81
|
-
rack (>= 1.0.0)
|
82
79
|
rack-ssl (1.3.2)
|
83
80
|
rack
|
84
81
|
rack-test (0.6.1)
|
85
82
|
rack (>= 1.0)
|
86
|
-
rails (3.
|
87
|
-
actionmailer (= 3.
|
88
|
-
actionpack (= 3.
|
89
|
-
activerecord (= 3.
|
90
|
-
activeresource (= 3.
|
91
|
-
activesupport (= 3.
|
83
|
+
rails (3.2.3)
|
84
|
+
actionmailer (= 3.2.3)
|
85
|
+
actionpack (= 3.2.3)
|
86
|
+
activerecord (= 3.2.3)
|
87
|
+
activeresource (= 3.2.3)
|
88
|
+
activesupport (= 3.2.3)
|
92
89
|
bundler (~> 1.0)
|
93
|
-
railties (= 3.
|
94
|
-
railties (3.
|
95
|
-
actionpack (= 3.
|
96
|
-
activesupport (= 3.
|
90
|
+
railties (= 3.2.3)
|
91
|
+
railties (3.2.3)
|
92
|
+
actionpack (= 3.2.3)
|
93
|
+
activesupport (= 3.2.3)
|
97
94
|
rack-ssl (~> 1.3.2)
|
98
95
|
rake (>= 0.8.7)
|
99
96
|
rdoc (~> 3.4)
|
100
97
|
thor (~> 0.14.6)
|
101
|
-
rake (0.9.2)
|
102
|
-
rdoc (3.
|
103
|
-
|
104
|
-
|
105
|
-
rspec-
|
106
|
-
rspec-
|
107
|
-
|
108
|
-
rspec-
|
109
|
-
|
110
|
-
|
111
|
-
rspec-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
98
|
+
rake (0.9.2.2)
|
99
|
+
rdoc (3.12)
|
100
|
+
json (~> 1.4)
|
101
|
+
rspec (2.9.0)
|
102
|
+
rspec-core (~> 2.9.0)
|
103
|
+
rspec-expectations (~> 2.9.0)
|
104
|
+
rspec-mocks (~> 2.9.0)
|
105
|
+
rspec-core (2.9.0)
|
106
|
+
rspec-expectations (2.9.1)
|
107
|
+
diff-lcs (~> 1.1.3)
|
108
|
+
rspec-mocks (2.9.0)
|
109
|
+
rspec-rails (2.9.0)
|
110
|
+
actionpack (>= 3.0)
|
111
|
+
activesupport (>= 3.0)
|
112
|
+
railties (>= 3.0)
|
113
|
+
rspec (~> 2.9.0)
|
114
|
+
rubyzip (0.9.7)
|
115
|
+
selenium-webdriver (2.21.2)
|
116
|
+
childprocess (>= 0.2.5)
|
117
|
+
ffi (~> 1.0)
|
118
|
+
libwebsocket (~> 0.1.3)
|
119
|
+
multi_json (~> 1.0)
|
121
120
|
rubyzip
|
122
|
-
spork (0.
|
123
|
-
sprockets (2.
|
121
|
+
spork (0.9.0)
|
122
|
+
sprockets (2.1.2)
|
124
123
|
hike (~> 1.2)
|
125
124
|
rack (~> 1.0)
|
126
|
-
tilt (
|
127
|
-
|
128
|
-
|
129
|
-
term-ansicolor (1.0.6)
|
125
|
+
tilt (~> 1.1, != 1.3.0)
|
126
|
+
sqlite3 (1.3.6)
|
127
|
+
term-ansicolor (1.0.7)
|
130
128
|
thor (0.14.6)
|
131
129
|
tilt (1.3.3)
|
132
130
|
treetop (1.4.10)
|
133
131
|
polyglot
|
134
132
|
polyglot (>= 0.3.1)
|
135
|
-
tzinfo (0.3.
|
133
|
+
tzinfo (0.3.33)
|
136
134
|
xpath (0.1.4)
|
137
135
|
nokogiri (~> 1.3)
|
138
136
|
|
@@ -145,7 +143,8 @@ DEPENDENCIES
|
|
145
143
|
cucumber-rails
|
146
144
|
database_cleaner
|
147
145
|
launchy
|
148
|
-
|
146
|
+
netzke-persistence
|
147
|
+
rails (= 3.2.3)
|
149
148
|
rspec-rails
|
150
149
|
spork
|
151
150
|
sqlite3
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Warning: The database defined as "test" will be erased and
|
2
|
+
# re-generated from your development database when you run "rake".
|
3
|
+
# Do not set this db to the same as development or production.
|
4
|
+
test: &test
|
5
|
+
adapter: mysql2
|
6
|
+
encoding: utf8
|
7
|
+
reconnect: false
|
8
|
+
database: nct_test
|
9
|
+
pool: 5
|
10
|
+
username:
|
11
|
+
|
12
|
+
cucumber:
|
13
|
+
<<: *test
|
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.1.4'
|
4
|
+
gem 'netzke-persistence'
|
5
|
+
|
6
|
+
gem 'mysql2'
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'capybara'
|
10
|
+
gem 'database_cleaner'
|
11
|
+
gem 'cucumber-rails', :require => false
|
12
|
+
gem 'cucumber'
|
13
|
+
gem 'rspec-rails'
|
14
|
+
gem 'spork'
|
15
|
+
gem 'launchy' # So you can do Then show me the page
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.2.3'
|
4
|
+
gem 'netzke-persistence'
|
5
|
+
|
6
|
+
gem 'mysql2'
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'capybara'
|
10
|
+
gem 'database_cleaner'
|
11
|
+
gem 'cucumber-rails', :require => false
|
12
|
+
gem 'cucumber'
|
13
|
+
gem 'rspec-rails'
|
14
|
+
gem 'spork'
|
15
|
+
gem 'launchy' # So you can do Then show me the page
|
16
|
+
end
|
@@ -16,8 +16,8 @@ module Netzke
|
|
16
16
|
|
17
17
|
def components
|
18
18
|
{
|
19
|
-
:nested_one => {:class_name => 'NestedComponentOne'},
|
20
|
-
:nested_two => {:class_name => 'NestedComponentTwo'}
|
19
|
+
:nested_one => {:class_name => 'Netzke::NestedComponentOne'},
|
20
|
+
:nested_two => {:class_name => 'Netzke::NestedComponentTwo'}
|
21
21
|
}
|
22
22
|
end
|
23
23
|
|
@@ -39,7 +39,7 @@ module Netzke
|
|
39
39
|
class NestedComponentTwo < Base
|
40
40
|
def components
|
41
41
|
{
|
42
|
-
:nested => {:class_name => 'DeepNestedComponent'}
|
42
|
+
:nested => {:class_name => 'Netzke::DeepNestedComponent'}
|
43
43
|
}
|
44
44
|
end
|
45
45
|
end
|
@@ -47,7 +47,7 @@ module Netzke
|
|
47
47
|
class DeepNestedComponent < Base
|
48
48
|
def components
|
49
49
|
{
|
50
|
-
:nested => {:class_name => "VeryDeepNestedComponent"}
|
50
|
+
:nested => {:class_name => "Netzke::VeryDeepNestedComponent"}
|
51
51
|
}
|
52
52
|
end
|
53
53
|
end
|
@@ -64,7 +64,7 @@ module Netzke
|
|
64
64
|
class SomeComposite < Base
|
65
65
|
component :component_one do
|
66
66
|
{
|
67
|
-
:class_name => "ComponentOne",
|
67
|
+
:class_name => "Netzke::ComponentOne",
|
68
68
|
:title => "My Cool Component"
|
69
69
|
}
|
70
70
|
end
|
@@ -72,8 +72,8 @@ module Netzke
|
|
72
72
|
def config
|
73
73
|
{
|
74
74
|
:items => [
|
75
|
-
{:class_name => "ComponentTwo", :name => "my_component_two"},
|
76
|
-
{:class_name => "ComponentTwo"} # name omitted, will be "
|
75
|
+
{:class_name => "Netzke::ComponentTwo", :name => "my_component_two"},
|
76
|
+
{:class_name => "Netzke::ComponentTwo"} # name omitted, will be "netzke_1"
|
77
77
|
]
|
78
78
|
}.deep_merge super
|
79
79
|
end
|
@@ -102,9 +102,9 @@ module Netzke
|
|
102
102
|
components = composite.components
|
103
103
|
|
104
104
|
components.keys.size.should == 3
|
105
|
-
components[:component_one][:class_name].should == "ComponentOne"
|
106
|
-
components[:my_component_two][:class_name].should == "ComponentTwo"
|
107
|
-
components[:
|
105
|
+
components[:component_one][:class_name].should == "Netzke::ComponentOne"
|
106
|
+
components[:my_component_two][:class_name].should == "Netzke::ComponentTwo"
|
107
|
+
components[:netzke_1][:class_name].should == "Netzke::ComponentTwo"
|
108
108
|
|
109
109
|
end
|
110
110
|
|
data/test/test_helper.rb
CHANGED
@@ -1,21 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# Load the Rails environment and testing framework
|
5
|
-
require "#{File.dirname(__FILE__)}/app_root/config/environment"
|
6
|
-
require 'test_help'
|
7
|
-
|
8
|
-
# Undo changes to RAILS_ENV
|
9
|
-
silence_warnings {RAILS_ENV = ENV['RAILS_ENV']}
|
10
|
-
|
11
|
-
# Run the migrations
|
12
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
|
13
|
-
|
14
|
-
# Set default fixture loading properties
|
15
|
-
ActiveSupport::TestCase.class_eval do
|
16
|
-
self.use_transactional_fixtures = true
|
17
|
-
self.use_instantiated_fixtures = false
|
18
|
-
self.fixture_path = "#{File.dirname(__FILE__)}/fixtures"
|
19
|
-
|
20
|
-
fixtures :all
|
21
|
-
end
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'netzke-core'
|
data/test/unit/core_ext_test.rb
CHANGED
@@ -27,18 +27,6 @@ class CoreExtTest < ActiveSupport::TestCase
|
|
27
27
|
],[:a_b => 1, :c_d_d => [{:look_ma => true},{:wow_now => true}]].deep_convert_keys{|k| k.to_s.camelize(:lower).to_sym})
|
28
28
|
end
|
29
29
|
|
30
|
-
test "javascript-like access to hash data" do
|
31
|
-
a = {}
|
32
|
-
a["b"] = 100
|
33
|
-
assert_equal(100, a.b)
|
34
|
-
|
35
|
-
a.b = 200
|
36
|
-
assert_equal(200, a["b"])
|
37
|
-
|
38
|
-
a.c = 300
|
39
|
-
assert_equal(300, a[:c])
|
40
|
-
end
|
41
|
-
|
42
30
|
test "jsonify" do
|
43
31
|
assert_equal({:aB => 1, "cD" => [[1, {:eF => "stay_same"}], {"literal_symbol" => :should_not_change, "literal_string".l => "also_should_not"}]}, {:a_b => 1, "c_d" => [[1, {:e_f => "stay_same"}], {:literal_symbol.l => :should_not_change, "literal_string".l => "also_should_not"}]}.jsonify)
|
44
32
|
end
|
@@ -70,4 +58,4 @@ class CoreExtTest < ActiveSupport::TestCase
|
|
70
58
|
end
|
71
59
|
end
|
72
60
|
|
73
|
-
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netzke-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70275002910340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70275002910340
|
25
25
|
description: Allows building DRY ExtJS/Rails applications by enabling modular development
|
26
26
|
email: nmcoder@gmail.com
|
27
27
|
executables: []
|
@@ -31,6 +31,7 @@ extra_rdoc_files:
|
|
31
31
|
- README.md
|
32
32
|
files:
|
33
33
|
- .autotest
|
34
|
+
- .travis.yml
|
34
35
|
- CHANGELOG.rdoc
|
35
36
|
- LICENSE
|
36
37
|
- Manifest
|
@@ -38,6 +39,7 @@ files:
|
|
38
39
|
- Rakefile
|
39
40
|
- TODO.md
|
40
41
|
- app/controllers/netzke_controller.rb
|
42
|
+
- config/ci/before-travis.sh
|
41
43
|
- init.rb
|
42
44
|
- install.rb
|
43
45
|
- javascripts/base.js
|
@@ -84,6 +86,7 @@ files:
|
|
84
86
|
- netzke-core.gemspec
|
85
87
|
- stylesheets/core.css
|
86
88
|
- test/core_test_app/.gitignore
|
89
|
+
- test/core_test_app/.powrc
|
87
90
|
- test/core_test_app/.rvmrc
|
88
91
|
- test/core_test_app/Gemfile
|
89
92
|
- test/core_test_app/Gemfile.lock
|
@@ -163,6 +166,7 @@ files:
|
|
163
166
|
- test/core_test_app/config/application.rb
|
164
167
|
- test/core_test_app/config/boot.rb
|
165
168
|
- test/core_test_app/config/database.yml
|
169
|
+
- test/core_test_app/config/database.yml.travis
|
166
170
|
- test/core_test_app/config/environment.rb
|
167
171
|
- test/core_test_app/config/environments/development.rb
|
168
172
|
- test/core_test_app/config/environments/production.rb
|
@@ -205,6 +209,8 @@ files:
|
|
205
209
|
- test/core_test_app/features/support/env.rb
|
206
210
|
- test/core_test_app/features/support/paths.rb
|
207
211
|
- test/core_test_app/features/touch.feature
|
212
|
+
- test/core_test_app/gemfiles/rails3_1.gemfile
|
213
|
+
- test/core_test_app/gemfiles/rails3_2.gemfile
|
208
214
|
- test/core_test_app/lib/tasks/.gitkeep
|
209
215
|
- test/core_test_app/public/404.html
|
210
216
|
- test/core_test_app/public/422.html
|
@@ -225,12 +231,9 @@ files:
|
|
225
231
|
- test/core_test_app/spec/spec_helper.rb
|
226
232
|
- test/core_test_app/tmp/restart.txt
|
227
233
|
- test/core_test_app/vendor/plugins/.gitkeep
|
228
|
-
- test/fixtures/roles.yml
|
229
|
-
- test/fixtures/users.yml
|
230
234
|
- test/test_helper.rb
|
231
235
|
- test/unit/core_ext_test.rb
|
232
236
|
- test/unit/netzke_core_test.rb
|
233
|
-
- test/unit/netzke_preference_test.rb
|
234
237
|
- uninstall.rb
|
235
238
|
homepage: http://netzke.org
|
236
239
|
licenses: []
|
data/test/fixtures/roles.yml
DELETED
data/test/fixtures/users.yml
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'netzke-core'
|
3
|
-
class NetzkePreferenceTest < ActiveSupport::TestCase
|
4
|
-
test "pref to read-write" do
|
5
|
-
p = NetzkePreference
|
6
|
-
session = Netzke::Core.session
|
7
|
-
session.clear
|
8
|
-
|
9
|
-
assert_not_nil(p.pref_to_write(:test))
|
10
|
-
p[:test] = "a value"
|
11
|
-
assert_not_nil(p.pref_to_read(:test))
|
12
|
-
end
|
13
|
-
|
14
|
-
test "basic values" do
|
15
|
-
an_integer = 1976
|
16
|
-
a_float = 1976.1345
|
17
|
-
a_symbol = :a_symbol
|
18
|
-
a_true = true
|
19
|
-
a_false = false
|
20
|
-
a_nil = nil
|
21
|
-
a_hash = {"a" => an_integer, "b" => a_true, "c" => nil, "d" => a_float}
|
22
|
-
an_array = [1, "a", a_hash, [1,3,4], a_true, a_false, a_nil, a_float]
|
23
|
-
|
24
|
-
|
25
|
-
p = NetzkePreference
|
26
|
-
p[:a_hash] = a_hash
|
27
|
-
p["an_integer"] = an_integer
|
28
|
-
p[:a_true] = a_true
|
29
|
-
p[:a_false] = a_false
|
30
|
-
p[:a_nil] = a_nil
|
31
|
-
p[:an_array] = an_array
|
32
|
-
p[:a_symbol] = a_symbol
|
33
|
-
p[:a_float] = a_float
|
34
|
-
|
35
|
-
assert_equal(a_hash, p[:a_hash])
|
36
|
-
assert_equal(an_integer, p[:an_integer])
|
37
|
-
assert_equal(a_true, p[:a_true])
|
38
|
-
assert_equal(a_false, p[:a_false])
|
39
|
-
assert_equal(an_array, p[:an_array])
|
40
|
-
assert_equal(a_nil, p[:a_nil])
|
41
|
-
assert_equal(a_symbol, p[:a_symbol])
|
42
|
-
assert_equal(a_float, p[:a_float])
|
43
|
-
|
44
|
-
assert_equal(nil, p[:non_existing])
|
45
|
-
end
|
46
|
-
|
47
|
-
test "multi-user/multi-role support" do
|
48
|
-
p = NetzkePreference
|
49
|
-
session = Netzke::Core.session
|
50
|
-
|
51
|
-
admin_role = Role.create(:name => 'admin')
|
52
|
-
user_role = Role.create(:name => 'user')
|
53
|
-
|
54
|
-
admin1 = User.create(:login => 'admin1', :role => admin_role)
|
55
|
-
user1 = User.create(:login => 'user1', :role => user_role)
|
56
|
-
user2 = User.create(:login => 'user2', :role => user_role)
|
57
|
-
|
58
|
-
#
|
59
|
-
# assign a value for a role, then read it back by users with the same role
|
60
|
-
#
|
61
|
-
session.clear
|
62
|
-
session[:masq_role] = user_role.id
|
63
|
-
p[:test] = 100
|
64
|
-
|
65
|
-
# first user
|
66
|
-
session.clear
|
67
|
-
session[:netzke_user_id] = user1.id
|
68
|
-
assert_equal(100, p[:test])
|
69
|
-
|
70
|
-
# second user
|
71
|
-
session.clear
|
72
|
-
session[:netzke_user_id] = user2.id
|
73
|
-
assert_equal(100, p[:test])
|
74
|
-
|
75
|
-
#
|
76
|
-
# now overwrite the value for user2
|
77
|
-
#
|
78
|
-
p[:test] = 200
|
79
|
-
assert_equal(200, p[:test])
|
80
|
-
# .. and check that its still the same for user1
|
81
|
-
session.clear
|
82
|
-
session[:netzke_user_id] = user1.id
|
83
|
-
assert_equal(100, p[:test])
|
84
|
-
|
85
|
-
#
|
86
|
-
# now overwrite it for user1 by means of masq_user
|
87
|
-
#
|
88
|
-
session.clear
|
89
|
-
session[:masq_user] = user1.id
|
90
|
-
p[:test] = 300
|
91
|
-
assert_equal(300, p[:test])
|
92
|
-
# .. and check it's still the same for user2
|
93
|
-
session.clear
|
94
|
-
session[:masq_user] = user2.id
|
95
|
-
assert_equal(200, p[:test])
|
96
|
-
# .. and that a new user with role 'user' will still read the original value assigned for the role
|
97
|
-
user3 = User.create(:login => "user3", :role => user_role)
|
98
|
-
session.clear
|
99
|
-
session[:netzke_user_id] = user3.id
|
100
|
-
assert_equal(100, p[:test])
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|