Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make generated scaffold functional tests work inside API engines #21176

Merged

Conversation

y-yagi
Copy link
Member

@y-yagi y-yagi commented Aug 9, 2015

Currently, generated scaffold functional tests inside api engine will result in an error.

$ ./bin/rails new bukkits --mountable --api 
$ cd bukkits
$ ./bin/rails g scaffold Todo title:string body:string 
      invoke  active_record
      create    db/migrate/20150809124505_create_bukkits_todos.rb
      create    app/models/bukkits/todo.rb
      invoke    test_unit
      create      test/models/bukkits/todo_test.rb
      create      test/fixtures/bukkits/todos.yml
      invoke  resource_route
       route    resources :todos
      invoke  scaffold_controller
      create    app/controllers/bukkits/todos_controller.rb
      invoke    test_unit
      create      test/controllers/bukkits/todos_controller_test.rb 

$ ./bin/rails t
Run options: --seed 2562

# Running:

.EEEEE

Finished in 0.134508s, 44.6071 runs/s, 7.4345 assertions/s.

  1) Error:
Bukkits::TodosControllerTest#test_should_update_todo:
NoMethodError: undefined method `todos' for #<Bukkits::TodosControllerTest:0x007fa2a00a7ea0>



  2) Error:
Bukkits::TodosControllerTest#test_should_create_todo:
NoMethodError: undefined method `todos' for #<Bukkits::TodosControllerTest:0x007fa2a0874598>



  3) Error:
Bukkits::TodosControllerTest#test_should_destroy_todo:
NoMethodError: undefined method `todos' for #<Bukkits::TodosControllerTest:0x007fa2a0886130>



  4) Error:
Bukkits::TodosControllerTest#test_should_get_index:
NoMethodError: undefined method `todos' for #<Bukkits::TodosControllerTest:0x007fa2a088bcc0>



  5) Error:
Bukkits::TodosControllerTest#test_should_show_todo:
NoMethodError: undefined method `todos' for #<Bukkits::TodosControllerTest:0x007fa2a08898a8>


6 runs, 1 assertions, 0 failures, 5 errors, 0 skips

Failed tests:

bin/rails test /home/yaginuma/program/rails/master/bukkits/test/controllers/bukkits/todos_controller_test.rb:27
bin/rails test /home/yaginuma/program/rails/master/bukkits/test/controllers/bukkits/todos_controller_test.rb:14
bin/rails test /home/yaginuma/program/rails/master/bukkits/test/controllers/bukkits/todos_controller_test.rb:32
bin/rails test /home/yaginuma/program/rails/master/bukkits/test/controllers/bukkits/todos_controller_test.rb:9
bin/rails test /home/yaginuma/program/rails/master/bukkits/test/controllers/bukkits/todos_controller_test.rb:22 

This commit fixes so that the test that is generated to work properly.

* set engine's route in setup
* use fixture with engine namespace
rafaelfranca added a commit that referenced this pull request Aug 10, 2015
…ngine

make generated scaffold functional tests work inside API engines
@rafaelfranca rafaelfranca merged commit 6e6cfb6 into rails:master Aug 10, 2015
@y-yagi y-yagi deleted the fix_scaffold_tests_inside_api_engine branch August 10, 2015 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants