Description:
started cleaning up tests, fixed fixtures loading error, removed error when contest time limit is uninitialized
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r275:3720a1af46c5 - - 19 files changed: 76 inserted, 211 deleted
@@ -318,23 +318,23 | |||||
|
318 | end |
|
318 | end |
|
319 |
|
319 | ||
|
320 | return { |
|
320 | return { |
|
321 | :msg => "#{run_stat}\n#{time_stat}", |
|
321 | :msg => "#{run_stat}\n#{time_stat}", |
|
322 | :running_time => seconds, |
|
322 | :running_time => seconds, |
|
323 | :exit_status => run_stat, |
|
323 | :exit_status => run_stat, |
|
324 | :memory_usage => memory_used |
|
324 | :memory_usage => memory_used |
|
325 | } |
|
325 | } |
|
326 | end |
|
326 | end |
|
327 |
|
327 | ||
|
328 | def update_user_start_time |
|
328 | def update_user_start_time |
|
329 | user = User.find(session[:user_id]) |
|
329 | user = User.find(session[:user_id]) |
|
330 |
- |
|
330 | + user.update_start_time |
|
331 | end |
|
331 | end |
|
332 |
|
332 | ||
|
333 | def reject_announcement_refresh_when_logged_out |
|
333 | def reject_announcement_refresh_when_logged_out |
|
334 | if not session[:user_id] |
|
334 | if not session[:user_id] |
|
335 | render :text => 'Access forbidden', :status => 403 |
|
335 | render :text => 'Access forbidden', :status => 403 |
|
336 | end |
|
336 | end |
|
337 | end |
|
337 | end |
|
338 |
|
338 | ||
|
339 | end |
|
339 | end |
|
340 |
|
340 |
@@ -1,57 +1,63 | |||||
|
1 | require 'yaml' |
|
1 | require 'yaml' |
|
2 |
|
2 | ||
|
3 | # |
|
3 | # |
|
4 | # This class also contains various login of the system. |
|
4 | # This class also contains various login of the system. |
|
5 | # |
|
5 | # |
|
6 | class Configuration < ActiveRecord::Base |
|
6 | class Configuration < ActiveRecord::Base |
|
7 |
|
7 | ||
|
8 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
8 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
9 | TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout' |
|
9 | TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout' |
|
10 |
|
10 | ||
|
11 | - # set @@cache = true to only reload once. |
|
11 | + cattr_accessor :cache |
|
12 | - @@cache = false |
|
12 | + cattr_accessor :config_cache |
|
|
13 | + cattr_accessor :task_grading_info | ||
|
|
14 | + cattr_accessor :contest_time_str | ||
|
|
15 | + cattr_accessor :contest_time | ||
|
13 |
|
16 | ||
|
14 | - @@configurations = nil |
|
17 | + # set @@cache = true to only reload once. |
|
15 | - @@task_grading_info = nil |
|
18 | + Configuration.cache = false |
|
|
19 | + | ||
|
|
20 | + Configuration.config_cache = nil | ||
|
|
21 | + Configuration.task_grading_info = nil | ||
|
16 |
|
22 | ||
|
17 | def self.get(key) |
|
23 | def self.get(key) |
|
18 |
- if |
|
24 | + if Configuration.cache |
|
19 |
- if |
|
25 | + if Configuration.config_cache == nil |
|
20 | self.read_config |
|
26 | self.read_config |
|
21 | end |
|
27 | end |
|
22 |
- return |
|
28 | + return Configuration.config_cache[key] |
|
23 | else |
|
29 | else |
|
24 | return Configuration.read_one_key(key) |
|
30 | return Configuration.read_one_key(key) |
|
25 | end |
|
31 | end |
|
26 | end |
|
32 | end |
|
27 |
|
33 | ||
|
28 | def self.[](key) |
|
34 | def self.[](key) |
|
29 | self.get(key) |
|
35 | self.get(key) |
|
30 | end |
|
36 | end |
|
31 |
|
37 | ||
|
32 | def self.reload |
|
38 | def self.reload |
|
33 | self.read_config |
|
39 | self.read_config |
|
34 | end |
|
40 | end |
|
35 |
|
41 | ||
|
36 | def self.clear |
|
42 | def self.clear |
|
37 |
- |
|
43 | + Configuration.config_cache = nil |
|
38 | end |
|
44 | end |
|
39 |
|
45 | ||
|
40 | def self.cache? |
|
46 | def self.cache? |
|
41 | - @@cache |
|
47 | + Configuration.cache |
|
42 | end |
|
48 | end |
|
43 |
|
49 | ||
|
44 | def self.enable_caching |
|
50 | def self.enable_caching |
|
45 |
- |
|
51 | + Configuration.cache = true |
|
46 | end |
|
52 | end |
|
47 |
|
53 | ||
|
48 | # |
|
54 | # |
|
49 | # View decision |
|
55 | # View decision |
|
50 | # |
|
56 | # |
|
51 | def self.show_submitbox_to?(user) |
|
57 | def self.show_submitbox_to?(user) |
|
52 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
58 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
53 | return false if mode=='analysis' |
|
59 | return false if mode=='analysis' |
|
54 | if (mode=='contest') |
|
60 | if (mode=='contest') |
|
55 | return false if (user.site!=nil) and |
|
61 | return false if (user.site!=nil) and |
|
56 | ((user.site.started!=true) or (user.site.finished?)) |
|
62 | ((user.site.started!=true) or (user.site.finished?)) |
|
57 | end |
|
63 | end |
@@ -73,28 +79,28 | |||||
|
73 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
79 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
74 | early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY) |
|
80 | early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY) |
|
75 | if (mode=='contest') |
|
81 | if (mode=='contest') |
|
76 | return false if ((user.site!=nil) and |
|
82 | return false if ((user.site!=nil) and |
|
77 | ((user.site.started!=true) or |
|
83 | ((user.site.started!=true) or |
|
78 | (early_timeout and (user.site.time_left < 30.minutes)))) |
|
84 | (early_timeout and (user.site.time_left < 30.minutes)))) |
|
79 | end |
|
85 | end |
|
80 | return false if mode=='analysis' |
|
86 | return false if mode=='analysis' |
|
81 | return true |
|
87 | return true |
|
82 | end |
|
88 | end |
|
83 |
|
89 | ||
|
84 | def self.task_grading_info |
|
90 | def self.task_grading_info |
|
85 |
- if |
|
91 | + if Configuration.task_grading_info==nil |
|
86 | read_grading_info |
|
92 | read_grading_info |
|
87 | end |
|
93 | end |
|
88 |
- return |
|
94 | + return Configuration.task_grading_info |
|
89 | end |
|
95 | end |
|
90 |
|
96 | ||
|
91 | def self.standard_mode? |
|
97 | def self.standard_mode? |
|
92 | return get(SYSTEM_MODE_CONF_KEY) == 'standard' |
|
98 | return get(SYSTEM_MODE_CONF_KEY) == 'standard' |
|
93 | end |
|
99 | end |
|
94 |
|
100 | ||
|
95 | def self.contest_mode? |
|
101 | def self.contest_mode? |
|
96 | return get(SYSTEM_MODE_CONF_KEY) == 'contest' |
|
102 | return get(SYSTEM_MODE_CONF_KEY) == 'contest' |
|
97 | end |
|
103 | end |
|
98 |
|
104 | ||
|
99 | def self.indv_contest_mode? |
|
105 | def self.indv_contest_mode? |
|
100 | return get(SYSTEM_MODE_CONF_KEY) == 'indv-contest' |
|
106 | return get(SYSTEM_MODE_CONF_KEY) == 'indv-contest' |
@@ -103,70 +109,70 | |||||
|
103 | def self.time_limit_mode? |
|
109 | def self.time_limit_mode? |
|
104 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
110 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
105 | return ((mode == 'contest') or (mode == 'indv-contest')) |
|
111 | return ((mode == 'contest') or (mode == 'indv-contest')) |
|
106 | end |
|
112 | end |
|
107 |
|
113 | ||
|
108 | def self.analysis_mode? |
|
114 | def self.analysis_mode? |
|
109 | return get(SYSTEM_MODE_CONF_KEY) == 'analysis' |
|
115 | return get(SYSTEM_MODE_CONF_KEY) == 'analysis' |
|
110 | end |
|
116 | end |
|
111 |
|
117 | ||
|
112 | def self.contest_time_limit |
|
118 | def self.contest_time_limit |
|
113 | contest_time_str = Configuration['contest.time_limit'] |
|
119 | contest_time_str = Configuration['contest.time_limit'] |
|
114 |
|
120 | ||
|
115 |
- if not defined? |
|
121 | + if not defined? Configuration.contest_time_str |
|
116 |
- |
|
122 | + Configuration.contest_time_str = nil |
|
117 | end |
|
123 | end |
|
118 |
|
124 | ||
|
119 |
- if |
|
125 | + if Configuration.contest_time_str != contest_time_str |
|
120 |
- |
|
126 | + Configuration.contest_time_str = contest_time_str |
|
121 | if tmatch = /(\d+):(\d+)/.match(contest_time_str) |
|
127 | if tmatch = /(\d+):(\d+)/.match(contest_time_str) |
|
122 | h = tmatch[1].to_i |
|
128 | h = tmatch[1].to_i |
|
123 | m = tmatch[2].to_i |
|
129 | m = tmatch[2].to_i |
|
124 |
|
130 | ||
|
125 |
- |
|
131 | + Configuration.contest_time = h.hour + m.minute |
|
126 | else |
|
132 | else |
|
127 |
- |
|
133 | + Configuration.contest_time = nil |
|
128 | end |
|
134 | end |
|
129 | end |
|
135 | end |
|
130 |
- return |
|
136 | + return Configuration.contest_time |
|
131 | end |
|
137 | end |
|
132 |
|
138 | ||
|
133 | protected |
|
139 | protected |
|
134 |
|
140 | ||
|
135 | def self.convert_type(val,type) |
|
141 | def self.convert_type(val,type) |
|
136 | case type |
|
142 | case type |
|
137 | when 'string' |
|
143 | when 'string' |
|
138 | return val |
|
144 | return val |
|
139 |
|
145 | ||
|
140 | when 'integer' |
|
146 | when 'integer' |
|
141 | return val.to_i |
|
147 | return val.to_i |
|
142 |
|
148 | ||
|
143 | when 'boolean' |
|
149 | when 'boolean' |
|
144 | return (val=='true') |
|
150 | return (val=='true') |
|
145 | end |
|
151 | end |
|
146 | end |
|
152 | end |
|
147 |
|
153 | ||
|
148 | def self.read_config |
|
154 | def self.read_config |
|
149 |
- |
|
155 | + Configuration.config_cache = {} |
|
150 | Configuration.find(:all).each do |conf| |
|
156 | Configuration.find(:all).each do |conf| |
|
151 | key = conf.key |
|
157 | key = conf.key |
|
152 | val = conf.value |
|
158 | val = conf.value |
|
153 |
- |
|
159 | + Configuration.config_cache[key] = Configuration.convert_type(val,conf.value_type) |
|
154 | end |
|
160 | end |
|
155 | end |
|
161 | end |
|
156 |
|
162 | ||
|
157 | def self.read_one_key(key) |
|
163 | def self.read_one_key(key) |
|
158 | conf = Configuration.find_by_key(key) |
|
164 | conf = Configuration.find_by_key(key) |
|
159 | if conf |
|
165 | if conf |
|
160 | return Configuration.convert_type(conf.value,conf.value_type) |
|
166 | return Configuration.convert_type(conf.value,conf.value_type) |
|
161 | else |
|
167 | else |
|
162 | return nil |
|
168 | return nil |
|
163 | end |
|
169 | end |
|
164 | end |
|
170 | end |
|
165 |
|
171 | ||
|
166 | def self.read_grading_info |
|
172 | def self.read_grading_info |
|
167 | f = File.open(TASK_GRADING_INFO_FILENAME) |
|
173 | f = File.open(TASK_GRADING_INFO_FILENAME) |
|
168 |
- |
|
174 | + Configuration.task_grading_info = YAML.load(f) |
|
169 | f.close |
|
175 | f.close |
|
170 | end |
|
176 | end |
|
171 |
|
177 | ||
|
172 | end |
|
178 | end |
@@ -121,24 +121,27 | |||||
|
121 | users = User.find(:all) |
|
121 | users = User.find(:all) |
|
122 | return users.find_all { |u| !(u.admin?) and u.login.index(prefix)==0 } |
|
122 | return users.find_all { |u| !(u.admin?) and u.login.index(prefix)==0 } |
|
123 | end |
|
123 | end |
|
124 |
|
124 | ||
|
125 | # Contest information |
|
125 | # Contest information |
|
126 |
|
126 | ||
|
127 | def contest_time_left |
|
127 | def contest_time_left |
|
128 | if Configuration.contest_mode? |
|
128 | if Configuration.contest_mode? |
|
129 | return nil if site==nil |
|
129 | return nil if site==nil |
|
130 | return site.time_left |
|
130 | return site.time_left |
|
131 | elsif Configuration.indv_contest_mode? |
|
131 | elsif Configuration.indv_contest_mode? |
|
132 | time_limit = Configuration.contest_time_limit |
|
132 | time_limit = Configuration.contest_time_limit |
|
|
133 | + if time_limit == nil | ||
|
|
134 | + return nil | ||
|
|
135 | + end | ||
|
133 | if contest_stat==nil |
|
136 | if contest_stat==nil |
|
134 | return (Time.now.gmtime + time_limit) - Time.now.gmtime |
|
137 | return (Time.now.gmtime + time_limit) - Time.now.gmtime |
|
135 | else |
|
138 | else |
|
136 | finish_time = contest_stat.started_at + time_limit |
|
139 | finish_time = contest_stat.started_at + time_limit |
|
137 | current_time = Time.now.gmtime |
|
140 | current_time = Time.now.gmtime |
|
138 | if current_time > finish_time |
|
141 | if current_time > finish_time |
|
139 | return 0 |
|
142 | return 0 |
|
140 | else |
|
143 | else |
|
141 | return finish_time - current_time |
|
144 | return finish_time - current_time |
|
142 | end |
|
145 | end |
|
143 | end |
|
146 | end |
|
144 | else |
|
147 | else |
@@ -161,24 +164,33 | |||||
|
161 | end |
|
164 | end |
|
162 | end |
|
165 | end |
|
163 |
|
166 | ||
|
164 | def contest_started? |
|
167 | def contest_started? |
|
165 | if Configuration.contest_mode? |
|
168 | if Configuration.contest_mode? |
|
166 | return true if site==nil |
|
169 | return true if site==nil |
|
167 | return site.started |
|
170 | return site.started |
|
168 | else |
|
171 | else |
|
169 | return true |
|
172 | return true |
|
170 | end |
|
173 | end |
|
171 | end |
|
174 | end |
|
172 |
|
175 | ||
|
|
176 | + def update_start_time | ||
|
|
177 | + stat = self.contest_stat | ||
|
|
178 | + if stat == nil | ||
|
|
179 | + stat = UserContestStat.new(:user => self, | ||
|
|
180 | + :started_at => Time.now.gmtime) | ||
|
|
181 | + stat.save | ||
|
|
182 | + end | ||
|
|
183 | + end | ||
|
|
184 | + | ||
|
173 | protected |
|
185 | protected |
|
174 | def encrypt_new_password |
|
186 | def encrypt_new_password |
|
175 | return if password.blank? |
|
187 | return if password.blank? |
|
176 | self.salt = (10+rand(90)).to_s |
|
188 | self.salt = (10+rand(90)).to_s |
|
177 | self.hashed_password = User.encrypt(self.password,self.salt) |
|
189 | self.hashed_password = User.encrypt(self.password,self.salt) |
|
178 | end |
|
190 | end |
|
179 |
|
191 | ||
|
180 | def assign_default_site |
|
192 | def assign_default_site |
|
181 | # have to catch error when migrating (because self.site is not available). |
|
193 | # have to catch error when migrating (because self.site is not available). |
|
182 | begin |
|
194 | begin |
|
183 | if self.site==nil |
|
195 | if self.site==nil |
|
184 | self.site = Site.find_by_name('default') |
|
196 | self.site = Site.find_by_name('default') |
@@ -1,14 +1,5 | |||||
|
1 | class UserContestStat < ActiveRecord::Base |
|
1 | class UserContestStat < ActiveRecord::Base |
|
2 |
|
2 | ||
|
3 | belongs_to :user |
|
3 | belongs_to :user |
|
4 |
|
4 | ||
|
5 | - def self.update_user_start_time(user) |
|
||
|
6 | - stat = user.contest_stat |
|
||
|
7 | - if stat == nil |
|
||
|
8 | - stat = UserContestStat.new(:user => user, |
|
||
|
9 | - :started_at => Time.now.gmtime) |
|
||
|
10 | - stat.save |
|
||
|
11 | - end |
|
||
|
12 | - end |
|
||
|
13 | - |
|
||
|
14 | end |
|
5 | end |
@@ -3,15 +3,15 | |||||
|
3 | admin_role = Role.find_by_name('admin') |
|
3 | admin_role = Role.find_by_name('admin') |
|
4 |
|
4 | ||
|
5 | graders_right = Right.create(:name => 'graders_admin', |
|
5 | graders_right = Right.create(:name => 'graders_admin', |
|
6 | :controller => 'graders', |
|
6 | :controller => 'graders', |
|
7 | :action => 'all') |
|
7 | :action => 'all') |
|
8 |
|
8 | ||
|
9 | admin_role.rights << graders_right; |
|
9 | admin_role.rights << graders_right; |
|
10 | admin_role.save |
|
10 | admin_role.save |
|
11 | end |
|
11 | end |
|
12 |
|
12 | ||
|
13 | def self.down |
|
13 | def self.down |
|
14 | graders_right = Right.find_by_name('graders_admin') |
|
14 | graders_right = Right.find_by_name('graders_admin') |
|
15 | - graders_right.destroy |
|
15 | + graders_right.destroy if graders_right |
|
16 | end |
|
16 | end |
|
17 | end |
|
17 | end |
@@ -15,15 +15,15 | |||||
|
15 | end |
|
15 | end |
|
16 | end |
|
16 | end |
|
17 |
|
17 | ||
|
18 | user.site_id = default_site.id |
|
18 | user.site_id = default_site.id |
|
19 | user.save |
|
19 | user.save |
|
20 | end |
|
20 | end |
|
21 | end |
|
21 | end |
|
22 |
|
22 | ||
|
23 | def self.down |
|
23 | def self.down |
|
24 | remove_column :users, :site_id |
|
24 | remove_column :users, :site_id |
|
25 |
|
25 | ||
|
26 | default_site = Site.find_by_name('default') |
|
26 | default_site = Site.find_by_name('default') |
|
27 | - default_site.destroy |
|
27 | + default_site.destroy if default_site |
|
28 | end |
|
28 | end |
|
29 | end |
|
29 | end |
@@ -92,36 +92,34 | |||||
|
92 |
|
92 | ||
|
93 | create_table "messages", :force => true do |t| |
|
93 | create_table "messages", :force => true do |t| |
|
94 | t.integer "sender_id" |
|
94 | t.integer "sender_id" |
|
95 | t.integer "receiver_id" |
|
95 | t.integer "receiver_id" |
|
96 | t.integer "replying_message_id" |
|
96 | t.integer "replying_message_id" |
|
97 | t.text "body" |
|
97 | t.text "body" |
|
98 | t.boolean "replied" |
|
98 | t.boolean "replied" |
|
99 | t.datetime "created_at" |
|
99 | t.datetime "created_at" |
|
100 | t.datetime "updated_at" |
|
100 | t.datetime "updated_at" |
|
101 | end |
|
101 | end |
|
102 |
|
102 | ||
|
103 | create_table "problems", :force => true do |t| |
|
103 | create_table "problems", :force => true do |t| |
|
104 |
- t.string |
|
104 | + t.string "name", :limit => 30 |
|
105 |
- t.string |
|
105 | + t.string "full_name" |
|
106 |
- t.integer |
|
106 | + t.integer "full_score" |
|
107 |
- t.date |
|
107 | + t.date "date_added" |
|
108 |
- t.boolean |
|
108 | + t.boolean "available" |
|
109 |
- t.string |
|
109 | + t.string "url" |
|
110 |
- t.integer |
|
110 | + t.integer "description_id" |
|
111 |
- t.boolean |
|
111 | + t.boolean "test_allowed" |
|
112 |
- t.boolean |
|
112 | + t.boolean "output_only" |
|
113 | - t.integer "level", :default => 0 |
|
113 | + t.string "description_filename" |
|
114 | - t.datetime "updated_at" |
|
||
|
115 | - t.string "description_filename" |
|
||
|
116 | end |
|
114 | end |
|
117 |
|
115 | ||
|
118 | create_table "rights", :force => true do |t| |
|
116 | create_table "rights", :force => true do |t| |
|
119 | t.string "name" |
|
117 | t.string "name" |
|
120 | t.string "controller" |
|
118 | t.string "controller" |
|
121 | t.string "action" |
|
119 | t.string "action" |
|
122 | end |
|
120 | end |
|
123 |
|
121 | ||
|
124 | create_table "rights_roles", :id => false, :force => true do |t| |
|
122 | create_table "rights_roles", :id => false, :force => true do |t| |
|
125 | t.integer "right_id" |
|
123 | t.integer "right_id" |
|
126 | t.integer "role_id" |
|
124 | t.integer "role_id" |
|
127 | end |
|
125 | end |
@@ -201,25 +199,24 | |||||
|
201 | t.integer "request_number" |
|
199 | t.integer "request_number" |
|
202 | t.datetime "created_at" |
|
200 | t.datetime "created_at" |
|
203 | t.datetime "updated_at" |
|
201 | t.datetime "updated_at" |
|
204 | t.boolean "submitted" |
|
202 | t.boolean "submitted" |
|
205 | end |
|
203 | end |
|
206 |
|
204 | ||
|
207 | create_table "test_pairs", :force => true do |t| |
|
205 | create_table "test_pairs", :force => true do |t| |
|
208 | t.integer "problem_id" |
|
206 | t.integer "problem_id" |
|
209 | t.text "input", :limit => 16777215 |
|
207 | t.text "input", :limit => 16777215 |
|
210 | t.text "solution", :limit => 16777215 |
|
208 | t.text "solution", :limit => 16777215 |
|
211 | t.datetime "created_at" |
|
209 | t.datetime "created_at" |
|
212 | t.datetime "updated_at" |
|
210 | t.datetime "updated_at" |
|
213 | - t.integer "number" |
|
||
|
214 | end |
|
211 | end |
|
215 |
|
212 | ||
|
216 | create_table "test_requests", :force => true do |t| |
|
213 | create_table "test_requests", :force => true do |t| |
|
217 | t.integer "user_id" |
|
214 | t.integer "user_id" |
|
218 | t.integer "problem_id" |
|
215 | t.integer "problem_id" |
|
219 | t.integer "submission_id" |
|
216 | t.integer "submission_id" |
|
220 | t.string "input_file_name" |
|
217 | t.string "input_file_name" |
|
221 | t.string "output_file_name" |
|
218 | t.string "output_file_name" |
|
222 | t.string "running_stat" |
|
219 | t.string "running_stat" |
|
223 | t.integer "status" |
|
220 | t.integer "status" |
|
224 | t.datetime "updated_at" |
|
221 | t.datetime "updated_at" |
|
225 | t.datetime "submitted_at" |
|
222 | t.datetime "submitted_at" |
@@ -234,38 +231,28 | |||||
|
234 | end |
|
231 | end |
|
235 |
|
232 | ||
|
236 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
233 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
237 |
|
234 | ||
|
238 | create_table "user_contest_stats", :force => true do |t| |
|
235 | create_table "user_contest_stats", :force => true do |t| |
|
239 | t.integer "user_id" |
|
236 | t.integer "user_id" |
|
240 | t.datetime "started_at" |
|
237 | t.datetime "started_at" |
|
241 | t.datetime "created_at" |
|
238 | t.datetime "created_at" |
|
242 | t.datetime "updated_at" |
|
239 | t.datetime "updated_at" |
|
243 | end |
|
240 | end |
|
244 |
|
241 | ||
|
245 | create_table "users", :force => true do |t| |
|
242 | create_table "users", :force => true do |t| |
|
246 |
- t.string "login", |
|
243 | + t.string "login", :limit => 50 |
|
247 | t.string "full_name" |
|
244 | t.string "full_name" |
|
248 | t.string "hashed_password" |
|
245 | t.string "hashed_password" |
|
249 |
- t.string "salt", |
|
246 | + t.string "salt", :limit => 5 |
|
250 | t.string "alias" |
|
247 | t.string "alias" |
|
251 | t.string "email" |
|
248 | t.string "email" |
|
252 | t.integer "site_id" |
|
249 | t.integer "site_id" |
|
253 | t.integer "country_id" |
|
250 | t.integer "country_id" |
|
254 |
- t.boolean "activated", |
|
251 | + t.boolean "activated", :default => false |
|
255 | t.datetime "created_at" |
|
252 | t.datetime "created_at" |
|
256 | t.datetime "updated_at" |
|
253 | t.datetime "updated_at" |
|
257 | - t.string "member1_full_name" |
|
||
|
258 | - t.string "member2_full_name" |
|
||
|
259 | - t.string "member3_full_name" |
|
||
|
260 | - t.boolean "high_school" |
|
||
|
261 | - t.string "member1_school_name" |
|
||
|
262 | - t.string "member2_school_name" |
|
||
|
263 | - t.string "member3_school_name" |
|
||
|
264 | - t.string "school_name" |
|
||
|
265 | - t.string "province" |
|
||
|
266 | - t.integer "year" |
|
||
|
267 | end |
|
254 | end |
|
268 |
|
255 | ||
|
269 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
256 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
270 |
|
257 | ||
|
271 | end |
|
258 | end |
@@ -16,24 +16,25 | |||||
|
16 | @user = mock(User, :id => 1, :login => 'john') |
|
16 | @user = mock(User, :id => 1, :login => 'john') |
|
17 | @another_user = mock(User, :id => 2, :login => 'mary') |
|
17 | @another_user = mock(User, :id => 2, :login => 'mary') |
|
18 | end |
|
18 | end |
|
19 |
|
19 | ||
|
20 | it "should redirect user to login page when unlogged-in user try to access main/list" do |
|
20 | it "should redirect user to login page when unlogged-in user try to access main/list" do |
|
21 | get 'list' |
|
21 | get 'list' |
|
22 | response.should redirect_to(:action => 'login') |
|
22 | response.should redirect_to(:action => 'login') |
|
23 | end |
|
23 | end |
|
24 |
|
24 | ||
|
25 | it "should let user sees her own source" do |
|
25 | it "should let user sees her own source" do |
|
26 | Submission.should_receive(:find).with(@submission.id.to_s).and_return(@submission) |
|
26 | Submission.should_receive(:find).with(@submission.id.to_s).and_return(@submission) |
|
27 | User.should_receive(:find).with(1).and_return(@user) |
|
27 | User.should_receive(:find).with(1).and_return(@user) |
|
|
28 | + @user.should_receive(:update_start_time) | ||
|
28 | get 'source', {:id => @submission.id}, {:user_id => 1} |
|
29 | get 'source', {:id => @submission.id}, {:user_id => 1} |
|
29 | response.should be_success |
|
30 | response.should be_success |
|
30 | end |
|
31 | end |
|
31 |
|
32 | ||
|
32 | it "should let user sees her own compiler message" do |
|
33 | it "should let user sees her own compiler message" do |
|
33 | Submission.should_receive(:find).with(@submission.id.to_s).and_return(@submission) |
|
34 | Submission.should_receive(:find).with(@submission.id.to_s).and_return(@submission) |
|
34 | User.should_receive(:find).with(1).and_return(@user) |
|
35 | User.should_receive(:find).with(1).and_return(@user) |
|
35 | get 'compiler_msg', {:id => @submission.id}, {:user_id => 1} |
|
36 | get 'compiler_msg', {:id => @submission.id}, {:user_id => 1} |
|
36 | response.should be_success |
|
37 | response.should be_success |
|
37 | end |
|
38 | end |
|
38 |
|
39 | ||
|
39 | it "should not let user sees other user's source" do |
|
40 | it "should not let user sees other user's source" do |
@@ -9,25 +9,25 | |||||
|
9 | #require 'webrat/integrations/rspec-rails' |
|
9 | #require 'webrat/integrations/rspec-rails' |
|
10 |
|
10 | ||
|
11 | # Requires supporting files with custom matchers and macros, etc, |
|
11 | # Requires supporting files with custom matchers and macros, etc, |
|
12 | # in ./support/ and its subdirectories. |
|
12 | # in ./support/ and its subdirectories. |
|
13 | Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} |
|
13 | Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} |
|
14 |
|
14 | ||
|
15 | Spec::Runner.configure do |config| |
|
15 | Spec::Runner.configure do |config| |
|
16 | # If you're not using ActiveRecord you should remove these |
|
16 | # If you're not using ActiveRecord you should remove these |
|
17 | # lines, delete config/database.yml and disable :active_record |
|
17 | # lines, delete config/database.yml and disable :active_record |
|
18 | # in your config/boot.rb |
|
18 | # in your config/boot.rb |
|
19 | config.use_transactional_fixtures = true |
|
19 | config.use_transactional_fixtures = true |
|
20 | config.use_instantiated_fixtures = false |
|
20 | config.use_instantiated_fixtures = false |
|
21 |
- config.fixture_path = RAILS_ROOT + '/ |
|
21 | + config.fixture_path = RAILS_ROOT + '/test/fixtures/' |
|
22 |
|
22 | ||
|
23 | # == Fixtures |
|
23 | # == Fixtures |
|
24 | # |
|
24 | # |
|
25 | # You can declare fixtures for each example_group like this: |
|
25 | # You can declare fixtures for each example_group like this: |
|
26 | # describe "...." do |
|
26 | # describe "...." do |
|
27 | # fixtures :table_a, :table_b |
|
27 | # fixtures :table_a, :table_b |
|
28 | # |
|
28 | # |
|
29 | # Alternatively, if you prefer to declare them only once, you can |
|
29 | # Alternatively, if you prefer to declare them only once, you can |
|
30 | # do so right here. Just uncomment the next line and replace the fixture |
|
30 | # do so right here. Just uncomment the next line and replace the fixture |
|
31 | # names with your fixtures. |
|
31 | # names with your fixtures. |
|
32 | # |
|
32 | # |
|
33 | # config.global_fixtures = :table_a, :table_b |
|
33 | # config.global_fixtures = :table_a, :table_b |
@@ -1,18 +1,20 | |||||
|
1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
2 |
|
2 | ||
|
3 | <% |
|
3 | <% |
|
4 | User.public_class_method :encrypt |
|
4 | User.public_class_method :encrypt |
|
5 |
|
5 | ||
|
6 |
- |
|
6 | + salt = "abc" |
|
7 | %> |
|
7 | %> |
|
8 |
|
8 | ||
|
9 | john: |
|
9 | john: |
|
10 | login: john |
|
10 | login: john |
|
11 | - hashed_password: <%= User.encrypt("hello",SALT) %> |
|
11 | + full_name: john |
|
12 | - salt: <%= SALT %> |
|
12 | + hashed_password: <%= User.encrypt("hello",salt) %> |
|
|
13 | + salt: <%= salt %> | ||
|
13 | mary: |
|
14 | mary: |
|
14 | login: mary |
|
15 | login: mary |
|
15 | - hashed_password: <%= User.encrypt("goodbye",SALT) %> |
|
16 | + full_name: mary |
|
16 | - salt: <%= SALT %> |
|
17 | + hashed_password: <%= User.encrypt("goodbye",salt) %> |
|
|
18 | + salt: <%= salt %> | ||
|
17 | roles: admin |
|
19 | roles: admin |
|
18 |
|
20 |
@@ -1,45 +1,4 | |||||
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
2 |
|
2 | ||
|
3 | class AnnouncementsControllerTest < ActionController::TestCase |
|
3 | class AnnouncementsControllerTest < ActionController::TestCase |
|
4 | - def test_should_get_index |
|
||
|
5 | - get :index |
|
||
|
6 | - assert_response :success |
|
||
|
7 | - assert_not_nil assigns(:announcements) |
|
||
|
8 | - end |
|
||
|
9 | - |
|
||
|
10 | - def test_should_get_new |
|
||
|
11 | - get :new |
|
||
|
12 | - assert_response :success |
|
||
|
13 | - end |
|
||
|
14 | - |
|
||
|
15 | - def test_should_create_announcement |
|
||
|
16 | - assert_difference('Announcement.count') do |
|
||
|
17 | - post :create, :announcement => { } |
|
||
|
18 | - end |
|
||
|
19 | - |
|
||
|
20 | - assert_redirected_to announcement_path(assigns(:announcement)) |
|
||
|
21 | - end |
|
||
|
22 | - |
|
||
|
23 | - def test_should_show_announcement |
|
||
|
24 | - get :show, :id => announcements(:one).id |
|
||
|
25 | - assert_response :success |
|
||
|
26 | - end |
|
||
|
27 | - |
|
||
|
28 | - def test_should_get_edit |
|
||
|
29 | - get :edit, :id => announcements(:one).id |
|
||
|
30 | - assert_response :success |
|
||
|
31 | - end |
|
||
|
32 | - |
|
||
|
33 | - def test_should_update_announcement |
|
||
|
34 | - put :update, :id => announcements(:one).id, :announcement => { } |
|
||
|
35 | - assert_redirected_to announcement_path(assigns(:announcement)) |
|
||
|
36 | - end |
|
||
|
37 | - |
|
||
|
38 | - def test_should_destroy_announcement |
|
||
|
39 | - assert_difference('Announcement.count', -1) do |
|
||
|
40 | - delete :destroy, :id => announcements(:one).id |
|
||
|
41 | - end |
|
||
|
42 | - |
|
||
|
43 | - assert_redirected_to announcements_path |
|
||
|
44 | - end |
|
||
|
45 | end |
|
4 | end |
@@ -1,45 +1,4 | |||||
|
1 | require 'test_helper' |
|
1 | require 'test_helper' |
|
2 |
|
2 | ||
|
3 | class ContestsControllerTest < ActionController::TestCase |
|
3 | class ContestsControllerTest < ActionController::TestCase |
|
4 | - test "should get index" do |
|
||
|
5 | - get :index |
|
||
|
6 | - assert_response :success |
|
||
|
7 | - assert_not_nil assigns(:contests) |
|
||
|
8 | - end |
|
||
|
9 | - |
|
||
|
10 | - test "should get new" do |
|
||
|
11 | - get :new |
|
||
|
12 | - assert_response :success |
|
||
|
13 | - end |
|
||
|
14 | - |
|
||
|
15 | - test "should create contest" do |
|
||
|
16 | - assert_difference('Contest.count') do |
|
||
|
17 | - post :create, :contest => { } |
|
||
|
18 | - end |
|
||
|
19 | - |
|
||
|
20 | - assert_redirected_to contest_path(assigns(:contest)) |
|
||
|
21 | - end |
|
||
|
22 | - |
|
||
|
23 | - test "should show contest" do |
|
||
|
24 | - get :show, :id => contests(:one).to_param |
|
||
|
25 | - assert_response :success |
|
||
|
26 | - end |
|
||
|
27 | - |
|
||
|
28 | - test "should get edit" do |
|
||
|
29 | - get :edit, :id => contests(:one).to_param |
|
||
|
30 | - assert_response :success |
|
||
|
31 | - end |
|
||
|
32 | - |
|
||
|
33 | - test "should update contest" do |
|
||
|
34 | - put :update, :id => contests(:one).to_param, :contest => { } |
|
||
|
35 | - assert_redirected_to contest_path(assigns(:contest)) |
|
||
|
36 | - end |
|
||
|
37 | - |
|
||
|
38 | - test "should destroy contest" do |
|
||
|
39 | - assert_difference('Contest.count', -1) do |
|
||
|
40 | - delete :destroy, :id => contests(:one).to_param |
|
||
|
41 | - end |
|
||
|
42 | - |
|
||
|
43 | - assert_redirected_to contests_path |
|
||
|
44 | - end |
|
||
|
45 | end |
|
4 | end |
@@ -1,19 +1,19 | |||||
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
2 | require 'login_controller' |
|
2 | require 'login_controller' |
|
3 |
|
3 | ||
|
4 | # Re-raise errors caught by the controller. |
|
4 | # Re-raise errors caught by the controller. |
|
5 | class LoginController; def rescue_action(e) raise e end; end |
|
5 | class LoginController; def rescue_action(e) raise e end; end |
|
6 |
|
6 | ||
|
7 |
- class LoginControllerTest < |
|
7 | + class LoginControllerTest < ActionController::TestCase |
|
8 |
|
8 | ||
|
9 | fixtures :users |
|
9 | fixtures :users |
|
10 |
|
10 | ||
|
11 | def setup |
|
11 | def setup |
|
12 | @controller = LoginController.new |
|
12 | @controller = LoginController.new |
|
13 | @request = ActionController::TestRequest.new |
|
13 | @request = ActionController::TestRequest.new |
|
14 | @response = ActionController::TestResponse.new |
|
14 | @response = ActionController::TestResponse.new |
|
15 | end |
|
15 | end |
|
16 |
|
16 | ||
|
17 | # Replace this with your real tests. |
|
17 | # Replace this with your real tests. |
|
18 | def test_should_hide_index |
|
18 | def test_should_hide_index |
|
19 | get :index |
|
19 | get :index |
@@ -1,32 +1,20 | |||||
|
1 | - require File.dirname(__FILE__) + '/../test_helper' |
|
1 | + require File.dirname(__FILE__) + '/../test_helper' |
|
2 | - require 'main_controller' |
|
||
|
3 |
|
2 | ||
|
4 | - # Re-raise errors caught by the controller. |
|
3 | + class MainControllerTest < ActionController::TestCase |
|
5 | - class MainController; def rescue_action(e) raise e end; end |
|
4 | + fixtures :users |
|
6 | - |
|
||
|
7 | - class MainControllerTest < Test::Unit::TestCase |
|
||
|
8 | - |
|
||
|
9 | fixtures :problems |
|
5 | fixtures :problems |
|
10 | - fixtures :users |
|
||
|
11 |
|
6 | ||
|
12 | - def setup |
|
||
|
13 | - @controller = MainController.new |
|
||
|
14 | - @request = ActionController::TestRequest.new |
|
||
|
15 | - @response = ActionController::TestResponse.new |
|
||
|
16 | - end |
|
||
|
17 | - |
|
||
|
18 | - # Replace this with your real tests. |
|
||
|
19 | def test_should_redirect_new_user_to_login |
|
7 | def test_should_redirect_new_user_to_login |
|
20 | get :list |
|
8 | get :list |
|
21 | - assert_redirected_to :action => 'login' |
|
9 | + assert_redirected_to :controller => 'main', :action => 'login' |
|
22 | end |
|
10 | end |
|
23 |
|
11 | ||
|
24 | def test_should_list_available_problems_if_logged_in |
|
12 | def test_should_list_available_problems_if_logged_in |
|
25 | john = users(:john) |
|
13 | john = users(:john) |
|
26 | get :list, {}, {:user_id => john.id} |
|
14 | get :list, {}, {:user_id => john.id} |
|
27 |
|
15 | ||
|
28 | assert_template 'main/list' |
|
16 | assert_template 'main/list' |
|
29 | assert_select "table tr:nth-child(2)", :text => /\(add\)/ |
|
17 | assert_select "table tr:nth-child(2)", :text => /\(add\)/ |
|
30 | end |
|
18 | end |
|
31 |
|
19 | ||
|
32 | end |
|
20 | end |
@@ -1,19 +1,19 | |||||
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
2 | require 'problems_controller' |
|
2 | require 'problems_controller' |
|
3 |
|
3 | ||
|
4 | # Re-raise errors caught by the controller. |
|
4 | # Re-raise errors caught by the controller. |
|
5 | class ProblemsController; def rescue_action(e) raise e end; end |
|
5 | class ProblemsController; def rescue_action(e) raise e end; end |
|
6 |
|
6 | ||
|
7 |
- class ProblemsControllerTest < |
|
7 | + class ProblemsControllerTest < ActionController::TestCase |
|
8 | fixtures :problems |
|
8 | fixtures :problems |
|
9 |
|
9 | ||
|
10 | def setup |
|
10 | def setup |
|
11 | @controller = ProblemsController.new |
|
11 | @controller = ProblemsController.new |
|
12 | @request = ActionController::TestRequest.new |
|
12 | @request = ActionController::TestRequest.new |
|
13 | @response = ActionController::TestResponse.new |
|
13 | @response = ActionController::TestResponse.new |
|
14 |
|
14 | ||
|
15 | @first_id = problems(:first).id |
|
15 | @first_id = problems(:first).id |
|
16 | end |
|
16 | end |
|
17 |
|
17 | ||
|
18 | def test_index |
|
18 | def test_index |
|
19 | get :index |
|
19 | get :index |
@@ -1,45 +1,4 | |||||
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
2 |
|
2 | ||
|
3 | class SitesControllerTest < ActionController::TestCase |
|
3 | class SitesControllerTest < ActionController::TestCase |
|
4 | - def test_should_get_index |
|
||
|
5 | - get :index |
|
||
|
6 | - assert_response :success |
|
||
|
7 | - assert_not_nil assigns(:sites) |
|
||
|
8 | - end |
|
||
|
9 | - |
|
||
|
10 | - def test_should_get_new |
|
||
|
11 | - get :new |
|
||
|
12 | - assert_response :success |
|
||
|
13 | - end |
|
||
|
14 | - |
|
||
|
15 | - def test_should_create_site |
|
||
|
16 | - assert_difference('Site.count') do |
|
||
|
17 | - post :create, :site => { } |
|
||
|
18 | - end |
|
||
|
19 | - |
|
||
|
20 | - assert_redirected_to site_path(assigns(:site)) |
|
||
|
21 | - end |
|
||
|
22 | - |
|
||
|
23 | - def test_should_show_site |
|
||
|
24 | - get :show, :id => sites(:one).id |
|
||
|
25 | - assert_response :success |
|
||
|
26 | - end |
|
||
|
27 | - |
|
||
|
28 | - def test_should_get_edit |
|
||
|
29 | - get :edit, :id => sites(:one).id |
|
||
|
30 | - assert_response :success |
|
||
|
31 | - end |
|
||
|
32 | - |
|
||
|
33 | - def test_should_update_site |
|
||
|
34 | - put :update, :id => sites(:one).id, :site => { } |
|
||
|
35 | - assert_redirected_to site_path(assigns(:site)) |
|
||
|
36 | - end |
|
||
|
37 | - |
|
||
|
38 | - def test_should_destroy_site |
|
||
|
39 | - assert_difference('Site.count', -1) do |
|
||
|
40 | - delete :destroy, :id => sites(:one).id |
|
||
|
41 | - end |
|
||
|
42 | - |
|
||
|
43 | - assert_redirected_to sites_path |
|
||
|
44 | - end |
|
||
|
45 | end |
|
4 | end |
@@ -1,19 +1,19 | |||||
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
2 | require 'user_admin_controller' |
|
2 | require 'user_admin_controller' |
|
3 |
|
3 | ||
|
4 | # Re-raise errors caught by the controller. |
|
4 | # Re-raise errors caught by the controller. |
|
5 | class UserAdminController; def rescue_action(e) raise e end; end |
|
5 | class UserAdminController; def rescue_action(e) raise e end; end |
|
6 |
|
6 | ||
|
7 |
- class UserAdminControllerTest < |
|
7 | + class UserAdminControllerTest < ActionController::TestCase |
|
8 | fixtures :users |
|
8 | fixtures :users |
|
9 | fixtures :roles |
|
9 | fixtures :roles |
|
10 | fixtures :rights |
|
10 | fixtures :rights |
|
11 |
|
11 | ||
|
12 | def setup |
|
12 | def setup |
|
13 | @controller = UserAdminController.new |
|
13 | @controller = UserAdminController.new |
|
14 | @request = ActionController::TestRequest.new |
|
14 | @request = ActionController::TestRequest.new |
|
15 | @response = ActionController::TestResponse.new |
|
15 | @response = ActionController::TestResponse.new |
|
16 |
|
16 | ||
|
17 | @first_id = users(:john).id |
|
17 | @first_id = users(:john).id |
|
18 | @admin_id = users(:mary).id |
|
18 | @admin_id = users(:mary).id |
|
19 | end |
|
19 | end |
@@ -1,18 +1,18 | |||||
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
2 | require 'users_controller' |
|
2 | require 'users_controller' |
|
3 |
|
3 | ||
|
4 | # Re-raise errors caught by the controller. |
|
4 | # Re-raise errors caught by the controller. |
|
5 | class UsersController; def rescue_action(e) raise e end; end |
|
5 | class UsersController; def rescue_action(e) raise e end; end |
|
6 |
|
6 | ||
|
7 |
- class UsersControllerTest < |
|
7 | + class UsersControllerTest < ActionController::TestCase |
|
8 | def setup |
|
8 | def setup |
|
9 | @controller = UsersController.new |
|
9 | @controller = UsersController.new |
|
10 | @request = ActionController::TestRequest.new |
|
10 | @request = ActionController::TestRequest.new |
|
11 | @response = ActionController::TestResponse.new |
|
11 | @response = ActionController::TestResponse.new |
|
12 | end |
|
12 | end |
|
13 |
|
13 | ||
|
14 | # Replace this with your real tests. |
|
14 | # Replace this with your real tests. |
|
15 | def test_truth |
|
15 | def test_truth |
|
16 | assert true |
|
16 | assert true |
|
17 | end |
|
17 | end |
|
18 | end |
|
18 | end |
@@ -1,28 +1,29 | |||||
|
1 | ENV["RAILS_ENV"] = "test" |
|
1 | ENV["RAILS_ENV"] = "test" |
|
2 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") |
|
2 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") |
|
3 | require 'test_help' |
|
3 | require 'test_help' |
|
4 |
|
4 | ||
|
5 |
- class |
|
5 | + class ActiveSupport::TestCase |
|
6 | # Transactional fixtures accelerate your tests by wrapping each test method |
|
6 | # Transactional fixtures accelerate your tests by wrapping each test method |
|
7 | # in a transaction that's rolled back on completion. This ensures that the |
|
7 | # in a transaction that's rolled back on completion. This ensures that the |
|
8 | # test database remains unchanged so your fixtures don't have to be reloaded |
|
8 | # test database remains unchanged so your fixtures don't have to be reloaded |
|
9 | # between every test method. Fewer database queries means faster tests. |
|
9 | # between every test method. Fewer database queries means faster tests. |
|
10 | # |
|
10 | # |
|
11 | # Read Mike Clark's excellent walkthrough at |
|
11 | # Read Mike Clark's excellent walkthrough at |
|
12 | # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting |
|
12 | # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting |
|
13 | # |
|
13 | # |
|
14 | # Every Active Record database supports transactions except MyISAM tables |
|
14 | # Every Active Record database supports transactions except MyISAM tables |
|
15 | # in MySQL. Turn off transactional fixtures in this case; however, if you |
|
15 | # in MySQL. Turn off transactional fixtures in this case; however, if you |
|
16 | # don't care one way or the other, switching from MyISAM to InnoDB tables |
|
16 | # don't care one way or the other, switching from MyISAM to InnoDB tables |
|
17 | # is recommended. |
|
17 | # is recommended. |
|
18 | - self.use_transactional_fixtures = true |
|
18 | + |
|
|
19 | + self.use_transactional_fixtures = false | ||
|
19 |
|
20 | ||
|
20 | # Instantiated fixtures are slow, but give you @david where otherwise you |
|
21 | # Instantiated fixtures are slow, but give you @david where otherwise you |
|
21 | # would need people(:david). If you don't want to migrate your existing |
|
22 | # would need people(:david). If you don't want to migrate your existing |
|
22 | # test cases which use the @david style and don't mind the speed hit (each |
|
23 | # test cases which use the @david style and don't mind the speed hit (each |
|
23 | # instantiated fixtures translates to a database query per test method), |
|
24 | # instantiated fixtures translates to a database query per test method), |
|
24 | # then set this back to true. |
|
25 | # then set this back to true. |
|
25 | self.use_instantiated_fixtures = false |
|
26 | self.use_instantiated_fixtures = false |
|
26 |
|
27 | ||
|
27 | # Add more helper methods to be used by all tests here... |
|
28 | # Add more helper methods to be used by all tests here... |
|
28 | end |
|
29 | end |
You need to be logged in to leave comments.
Login now