Description:
fixed dependency errors in spec
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r293:463e9531da32 - - 6 files changed: 43 inserted, 39 deleted
@@ -0,0 +1,20 | |||||
|
|
1 | + | ||
|
|
2 | + module ConfigSpecHelperMethods | ||
|
|
3 | + | ||
|
|
4 | + def find_or_create_and_set_config(key, type, value) | ||
|
|
5 | + c = Configuration.find_by_key(key) | ||
|
|
6 | + c ||= Configuration.new(:key => key, | ||
|
|
7 | + :value_type => type) | ||
|
|
8 | + c.value = value | ||
|
|
9 | + c.save! | ||
|
|
10 | + end | ||
|
|
11 | + | ||
|
|
12 | + def enable_multicontest | ||
|
|
13 | + find_or_create_and_set_config('system.multicontests','boolean','true') | ||
|
|
14 | + end | ||
|
|
15 | + | ||
|
|
16 | + def disable_multicontest | ||
|
|
17 | + find_or_create_and_set_config('system.multicontests','boolean','false') | ||
|
|
18 | + end | ||
|
|
19 | + | ||
|
|
20 | + end |
@@ -107,6 +107,7 | |||||
|
107 | end |
|
107 | end |
|
108 |
|
108 | ||
|
109 | def self.multicontests? |
|
109 | def self.multicontests? |
|
|
110 | + g = get('system.multicontests') | ||
|
110 | return get('system.multicontests') == true |
|
111 | return get('system.multicontests') == true |
|
111 | end |
|
112 | end |
|
112 |
|
113 |
@@ -1,20 +1,5 | |||||
|
1 | require File.dirname(__FILE__) + '/../spec_helper' |
|
1 | require File.dirname(__FILE__) + '/../spec_helper' |
|
2 | - |
|
2 | + require File.dirname(__FILE__) + '/../config_spec_helper' |
|
3 | - module ConfigHelperMethods |
|
||
|
4 | - def enable_multicontest |
|
||
|
5 | - c = Configuration.new(:key => 'system.multicontests', |
|
||
|
6 | - :value_type => 'boolean', |
|
||
|
7 | - :value => 'true') |
|
||
|
8 | - c.save |
|
||
|
9 | - end |
|
||
|
10 | - |
|
||
|
11 | - def disable_multicontest |
|
||
|
12 | - c = Configuration.new(:key => 'system.multicontests', |
|
||
|
13 | - :value_type => 'boolean', |
|
||
|
14 | - :value => 'false') |
|
||
|
15 | - c.save |
|
||
|
16 | - end |
|
||
|
17 | - end |
|
||
|
18 |
|
3 | ||
|
19 | describe MainController, "when a user comes to list page" do |
|
4 | describe MainController, "when a user comes to list page" do |
|
20 |
|
5 | ||
@@ -28,7 +13,7 | |||||
|
28 | describe MainController, "when a logged in user comes to list page, with multicontests off" do |
|
13 | describe MainController, "when a logged in user comes to list page, with multicontests off" do |
|
29 | integrate_views |
|
14 | integrate_views |
|
30 |
|
15 | ||
|
31 | - include ConfigHelperMethods |
|
16 | + include ConfigSpecHelperMethods |
|
32 |
|
17 | ||
|
33 | fixtures :users |
|
18 | fixtures :users |
|
34 | fixtures :problems |
|
19 | fixtures :problems |
@@ -53,7 +38,7 | |||||
|
53 | describe MainController, "when a logged in user comes to list page, with multicontests on" do |
|
38 | describe MainController, "when a logged in user comes to list page, with multicontests on" do |
|
54 | integrate_views |
|
39 | integrate_views |
|
55 |
|
40 | ||
|
56 | - include ConfigHelperMethods |
|
41 | + include ConfigSpecHelperMethods |
|
57 |
|
42 | ||
|
58 | fixtures :users |
|
43 | fixtures :users |
|
59 | fixtures :problems |
|
44 | fixtures :problems |
@@ -17,6 +17,10 | |||||
|
17 | any_number_of_times. |
|
17 | any_number_of_times. |
|
18 | and_return(@john_activation_key) |
|
18 | and_return(@john_activation_key) |
|
19 |
|
19 | ||
|
|
20 | + Configuration.new(:key => 'system.online_registration', | ||
|
|
21 | + :value_type => 'boolean', | ||
|
|
22 | + :value => 'true').save | ||
|
|
23 | + | ||
|
20 | get :new |
|
24 | get :new |
|
21 | response.should render_template('users/new') |
|
25 | response.should render_template('users/new') |
|
22 | end |
|
26 | end |
@@ -1,14 +1,10 | |||||
|
1 |
|
1 | ||
|
2 | require File.dirname(__FILE__) + '/../spec_helper' |
|
2 | require File.dirname(__FILE__) + '/../spec_helper' |
|
3 |
|
3 | ||
|
4 | - describe Configuration do |
|
4 | + describe Configuration, "when using cache" do |
|
5 | - |
|
||
|
6 | - # only work with cached configuration |
|
||
|
7 | - class Configuration |
|
||
|
8 | - @@cache = true |
|
||
|
9 | - end |
|
||
|
10 |
|
5 | ||
|
11 | before(:each) do |
|
6 | before(:each) do |
|
|
7 | + Configuration.cache = true | ||
|
12 | @int_config = mock(Configuration, |
|
8 | @int_config = mock(Configuration, |
|
13 | :id => 1, |
|
9 | :id => 1, |
|
14 | :key => 'mode', |
|
10 | :key => 'mode', |
@@ -27,6 +23,10 | |||||
|
27 | :value_type => 'boolean', |
|
23 | :value_type => 'boolean', |
|
28 | :value => 'true') |
|
24 | :value => 'true') |
|
29 | end |
|
25 | end |
|
|
26 | + | ||
|
|
27 | + after(:each) do | ||
|
|
28 | + Configuration.cache = false | ||
|
|
29 | + end | ||
|
30 |
|
30 | ||
|
31 | it "should retrieve int config" do |
|
31 | it "should retrieve int config" do |
|
32 | Configuration.should_receive(:find).once.with(:all). |
|
32 | Configuration.should_receive(:find).once.with(:all). |
@@ -1,5 +1,5 | |||||
|
1 | - |
|
||
|
2 |
|
|
1 | require File.dirname(__FILE__) + '/../spec_helper' |
|
|
2 | + require File.dirname(__FILE__) + '/../config_spec_helper' | ||
|
3 |
|
3 | ||
|
4 | describe User do |
|
4 | describe User do |
|
5 |
|
5 | ||
@@ -104,6 +104,8 | |||||
|
104 | end |
|
104 | end |
|
105 |
|
105 | ||
|
106 | describe User, "when requesting problem description," do |
|
106 | describe User, "when requesting problem description," do |
|
|
107 | + | ||
|
|
108 | + include ConfigSpecHelperMethods | ||
|
107 |
|
109 | ||
|
108 | fixtures :users |
|
110 | fixtures :users |
|
109 | fixtures :problems |
|
111 | fixtures :problems |
@@ -134,9 +136,14 | |||||
|
134 |
|
136 | ||
|
135 | it "should not be able to view problem not in user's contests, when multicontests is on" do |
|
137 | it "should not be able to view problem not in user's contests, when multicontests is on" do |
|
136 | enable_multicontest |
|
138 | enable_multicontest |
|
|
139 | + @james.can_view_problem?(@hard).should be_false | ||
|
|
140 | + end | ||
|
|
141 | + | ||
|
|
142 | + it "with no assigned contest should not be able to view problem in contests when multicontests is on" do | ||
|
|
143 | + enable_multicontest | ||
|
|
144 | + @john.can_view_problem?(@add).should be_true | ||
|
137 | @john.can_view_problem?(@easy).should be_false |
|
145 | @john.can_view_problem?(@easy).should be_false |
|
138 | @john.can_view_problem?(@hard).should be_false |
|
146 | @john.can_view_problem?(@hard).should be_false |
|
139 | - @james.can_view_problem?(@hard).should be_false |
|
||
|
140 | end |
|
147 | end |
|
141 |
|
148 | ||
|
142 | it "should be able to view all available problems, when multicontests is off" do |
|
149 | it "should be able to view all available problems, when multicontests is off" do |
@@ -153,17 +160,4 | |||||
|
153 | @james.can_view_problem?(@add).should be_true |
|
160 | @james.can_view_problem?(@add).should be_true |
|
154 | end |
|
161 | end |
|
155 |
|
162 | ||
|
156 | - def enable_multicontest |
|
||
|
157 | - c = Configuration.new(:key => 'system.multicontests', |
|
||
|
158 | - :value_type => 'boolean', |
|
||
|
159 | - :value => 'true') |
|
||
|
160 | - c.save |
|
||
|
161 | - end |
|
||
|
162 | - |
|
||
|
163 | - def disable_multicontest |
|
||
|
164 | - c = Configuration.new(:key => 'system.multicontests', |
|
||
|
165 | - :value_type => 'boolean', |
|
||
|
166 | - :value => 'false') |
|
||
|
167 | - c.save |
|
||
|
168 | - end |
|
||
|
169 | end |
|
163 | end |
You need to be logged in to leave comments.
Login now