Commit 28ab6d02b1980982e2fd4dc4cf489bb17cae1d62
1 parent
057d1aa0
Exists in
colab
and in
4 other branches
Fixed controller tests for JS actions
Showing
2 changed files
with
7 additions
and
14 deletions
Show diff stats
spec/controllers/modules_controller_spec.rb
| @@ -4,9 +4,8 @@ describe ModulesController do | @@ -4,9 +4,8 @@ describe ModulesController do | ||
| 4 | describe "load_module_tree" do | 4 | describe "load_module_tree" do |
| 5 | before :each do | 5 | before :each do |
| 6 | ModuleResult.expects(:find).with(42).returns(FactoryGirl.build(:module_result)) | 6 | ModuleResult.expects(:find).with(42).returns(FactoryGirl.build(:module_result)) |
| 7 | - request.env["HTTP_ACCEPT"] = 'application/javascript' # FIXME: there should be a better way to force JS | ||
| 8 | 7 | ||
| 9 | - post :load_module_tree, {id: 42} | 8 | + post :load_module_tree, id: 42, format: :js |
| 10 | end | 9 | end |
| 11 | 10 | ||
| 12 | it { should respond_with(:success) } | 11 | it { should respond_with(:success) } |
| @@ -24,8 +23,7 @@ describe ModulesController do | @@ -24,8 +23,7 @@ describe ModulesController do | ||
| 24 | ModuleResult.expects(:find).at_least_once.with(module_result.id).returns(module_result) | 23 | ModuleResult.expects(:find).at_least_once.with(module_result.id).returns(module_result) |
| 25 | subject.expire_fragment("#{module_result.id}_#{metric_name}") | 24 | subject.expire_fragment("#{module_result.id}_#{metric_name}") |
| 26 | 25 | ||
| 27 | - request.env["HTTP_ACCEPT"] = 'application/javascript' # FIXME: there should be a better way to force JS | ||
| 28 | - get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id | 26 | + get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id, format: :js |
| 29 | end | 27 | end |
| 30 | 28 | ||
| 31 | it { should respond_with(:success) } | 29 | it { should respond_with(:success) } |
spec/controllers/repositories_controller_spec.rb
| @@ -251,8 +251,7 @@ describe RepositoriesController do | @@ -251,8 +251,7 @@ describe RepositoriesController do | ||
| 251 | repository.expects(:last_processing).returns(nil) | 251 | repository.expects(:last_processing).returns(nil) |
| 252 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) | 252 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
| 253 | 253 | ||
| 254 | - request.env["HTTP_ACCEPT"] = 'application/javascript' # FIXME: there should be a better way to force JS | ||
| 255 | - get :state, project_id: project.id.to_s, id: repository.id, last_state: '' | 254 | + get :state, project_id: project.id.to_s, id: repository.id, last_state: '', format: :js |
| 256 | end | 255 | end |
| 257 | 256 | ||
| 258 | it { should respond_with(:success) } | 257 | it { should respond_with(:success) } |
| @@ -266,8 +265,7 @@ describe RepositoriesController do | @@ -266,8 +265,7 @@ describe RepositoriesController do | ||
| 266 | repository.expects(:last_processing).returns(ready_processing) | 265 | repository.expects(:last_processing).returns(ready_processing) |
| 267 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) | 266 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
| 268 | 267 | ||
| 269 | - request.env["HTTP_ACCEPT"] = 'application/javascript' # FIXME: there should be a better way to force JS | ||
| 270 | - get :state, project_id: project.id.to_s, id: repository.id, last_state: 'ANALYZING' | 268 | + get :state, project_id: project.id.to_s, id: repository.id, last_state: 'ANALYZING', format: :js |
| 271 | end | 269 | end |
| 272 | 270 | ||
| 273 | it { should respond_with(:success) } | 271 | it { should respond_with(:success) } |
| @@ -281,8 +279,7 @@ describe RepositoriesController do | @@ -281,8 +279,7 @@ describe RepositoriesController do | ||
| 281 | repository.expects(:last_processing).returns(processing) | 279 | repository.expects(:last_processing).returns(processing) |
| 282 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) | 280 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
| 283 | 281 | ||
| 284 | - request.env["HTTP_ACCEPT"] = 'application/javascript' # FIXME: there should be a better way to force JS | ||
| 285 | - get :state, project_id: project.id.to_s, id: repository.id, last_state: 'LOADING' | 282 | + get :state, project_id: project.id.to_s, id: repository.id, last_state: 'LOADING', format: :js |
| 286 | end | 283 | end |
| 287 | 284 | ||
| 288 | it { should respond_with(:success) } | 285 | it { should respond_with(:success) } |
| @@ -293,8 +290,7 @@ describe RepositoriesController do | @@ -293,8 +290,7 @@ describe RepositoriesController do | ||
| 293 | before :each do | 290 | before :each do |
| 294 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) | 291 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
| 295 | 292 | ||
| 296 | - request.env["HTTP_ACCEPT"] = 'application/javascript' # FIXME: there should be a better way to force JS | ||
| 297 | - get :state, project_id: project.id.to_s, id: repository.id, last_state: 'READY' | 293 | + get :state, project_id: project.id.to_s, id: repository.id, last_state: 'READY', format: :js |
| 298 | end | 294 | end |
| 299 | 295 | ||
| 300 | it { should respond_with(:ok) } | 296 | it { should respond_with(:ok) } |
| @@ -308,8 +304,7 @@ describe RepositoriesController do | @@ -308,8 +304,7 @@ describe RepositoriesController do | ||
| 308 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) | 304 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
| 309 | Processing.expects(:processing_with_date_of).with(repository.id, "2013-11-11").returns(processing) | 305 | Processing.expects(:processing_with_date_of).with(repository.id, "2013-11-11").returns(processing) |
| 310 | 306 | ||
| 311 | - request.env["HTTP_ACCEPT"] = 'application/javascript' # FIXME: there should be a better way to force JS | ||
| 312 | - get :state, project_id: project.id.to_s, id: repository.id, last_state: '', day: '11', month: '11', year: '2013' | 307 | + get :state, project_id: project.id.to_s, id: repository.id, last_state: '', day: '11', month: '11', year: '2013', format: :js |
| 313 | end | 308 | end |
| 314 | 309 | ||
| 315 | it { should respond_with(:ok) } | 310 | it { should respond_with(:ok) } |