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

set engine's route in the functional test is generated in the engine #20387

Merged
merged 3 commits into from Jun 2, 2015
Merged

set engine's route in the functional test is generated in the engine #20387

merged 3 commits into from Jun 2, 2015

Conversation

y-yagi
Copy link
Member

@y-yagi y-yagi commented May 31, 2015

Currently, functional test is generated in the engine does not work properly.

$ ./bin/rails g controller Foo index
      create  app/controllers/blorgh/foo_controller.rb
       route  get 'foo/index'
      invoke  erb
      create    app/views/blorgh/foo
      create    app/views/blorgh/foo/index.html.erb
      invoke  test_unit
      create    test/controllers/blorgh/foo_controller_test.rb
      invoke  helper
      create    app/helpers/blorgh/foo_helper.rb
      invoke    test_unit
      invoke  assets
      invoke    js
      create      app/assets/javascripts/blorgh/foo.js
      invoke    css
      create      app/assets/stylesheets/blorgh/foo.css 

$ bundle exec rake
# Running:

E.

Finished in 0.055383s, 36.1122 runs/s, 18.0561 assertions/s.

  1) Error:
Blorgh::FooControllerTest#test_should_get_index:
ActionController::UrlGenerationError: No route matches {:action=>"index", :controller=>"blorgh/foo"}
    /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/journey/formatter.rb:46:in `generate'
    /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:727:in `generate'
    /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:758:in `generate'
    /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:753:in `generate_extras'
    /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:748:in `extra_keys'
    /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_controller/test_case.rb:208:in `assign_parameters'
    /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_controller/test_case.rb:619:in `process'
    /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_controller/test_case.rb:65:in `process'
    /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_controller/test_case.rb:508:in `get'
    /home/yaginuma/program/rails/rails_4-2-1_sample/blorgh/test/controllers/blorgh/foo_controller_test.rb:6:in `block in <class:FooControllerTest>'

2 runs, 1 assertions, 0 failures, 1 errors, 0 skips
rake aborted!
Command failed with status (1): [ruby -I"lib:lib:test"  "/home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/rake_test_loader.rb" "test/**/*_test.rb" ]

In order to work properly, need to set the @routes instance variable to the engine's route.

Therefore, I think good to have engine's route in the generated functional test is set.

@senny
Copy link
Member

senny commented May 31, 2015

@y-yagi this seems like a good idea. I'm wondering why we didn't notice that those tests are not working. I vaguely remember that we have some tests in railties that run generated test files. Could you explore to write such a test?

@y-yagi
Copy link
Member Author

y-yagi commented May 31, 2015

@senny Thank you for the review! I added test to run generated test files.
At that time, fixture name problem occurs, I was fixed together.

assert_match(/2 runs, 2 assertions, 0 failures, 0 errors/, `bundle exec rake test 2>&1`)
end

def test_generating_scaffold_controller_inside_mountable_engine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this test? Looks like a duplication of the one following right after.

@y-yagi
Copy link
Member Author

y-yagi commented Jun 2, 2015

@senny Thank you for the review!
Move the test to the appropriate place, and has been deleted duplicate test.

@senny
Copy link
Member

senny commented Jun 2, 2015

@y-yagi fantastic. Thank you 💛

I added an entry to the changelog in the merge-commit.

@senny senny merged commit 3612793 into rails:master Jun 2, 2015
senny added a commit that referenced this pull request Jun 2, 2015
…_test

set engine's route in the functional test is generated in the engine
senny added a commit that referenced this pull request Jun 2, 2015
…_test

set engine's route in the functional test is generated in the engine

Conflicts:
	railties/CHANGELOG.md
@y-yagi
Copy link
Member Author

y-yagi commented Jun 2, 2015

@senny Thanks!

@y-yagi y-yagi deleted the fix_engine_generated_controller_test branch June 2, 2015 14:31
@senny senny modified the milestone: 4.2.4 Jun 29, 2015
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.

None yet

2 participants