Project

General

Profile

Actions

Refactor #16557

closed

Move tests into test/models, controllers, helpers dirs.

Added by Dominic Cleal over 7 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Tests
Target version:
Fixed in Releases:
Found in Releases:

Description

Rails 4 recommends using test/models/, test/controllers/, test/mailers/ and test/helpers/ to match the app/ layout for tests rather than having test/unit/ contain model and general unit/service object tests.

This is also important under Rails 5 which fails to run rake test when these directories don't exist:

$ rake test:units
rake aborted!
LoadError: cannot load such file -- /home/dcleal/code/foreman/foreman/test/models
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `block in require'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-5.0.0/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-5.0.0/lib/rails/test_unit/test_requirer.rb:10:in `each'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-5.0.0/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-5.0.0/lib/rails/test_unit/minitest_plugin.rb:76:in `plugin_rails_init'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/minitest-5.1.0/lib/minitest.rb:73:in `block in init_plugins'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/minitest-5.1.0/lib/minitest.rb:71:in `each'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/minitest-5.1.0/lib/minitest.rb:71:in `init_plugins'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/minitest-5.1.0/lib/minitest.rb:122:in `run'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-5.0.0/lib/rails/test_unit/minitest_plugin.rb:64:in `rake_run'
/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-5.0.0/lib/rails/test_unit/testing.rake:43:in `block (2 levels) in <top (required)>'

Moving models into test/models/ and using test/unit/ for other objects would also allow test/lib/ to be rolled into test/unit/ in a more logical way, which allows us to remove the custom test:lib rake task.

(http://guides.rubyonrails.org/testing.html#rails-sets-up-for-testing-from-the-word-go and https://github.com/rails/rails/blob/4-2-stable/railties/lib/rails/test_unit/testing.rake show possible directories)


Related issues 3 (0 open3 closed)

Related to Foreman - Bug #16700: Intermittent AboutIntegrationTest.test_0001_about page integration test failuresClosedDominic Cleal09/27/2016Actions
Related to Foreman - Bug #16821: AccessPermissionsTest does not pick up plugin permissionsClosedDominic Cleal10/06/2016Actions
Related to Foreman - Bug #18695: Missing test/functional/ directory causes rake test:functionals failureClosedDominic Cleal02/27/2017Actions
Actions #1

Updated by The Foreman Bot over 7 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3843 added
Actions #2

Updated by Dominic Cleal over 7 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #3

Updated by The Foreman Bot over 7 years ago

  • Pull request https://github.com/theforeman/foreman/pull/3888 added
Actions #4

Updated by Dominic Cleal over 7 years ago

  • translation missing: en.field_release set to 189
Actions #5

Updated by Dominic Cleal over 7 years ago

  • Related to Bug #16700: Intermittent AboutIntegrationTest.test_0001_about page integration test failures added
Actions #6

Updated by Dominic Cleal over 7 years ago

  • Related to Bug #16821: AccessPermissionsTest does not pick up plugin permissions added
Actions #7

Updated by Dominic Cleal about 7 years ago

  • Related to Bug #18695: Missing test/functional/ directory causes rake test:functionals failure added
Actions

Also available in: Atom PDF