YaleSTC / shifts

Application to easily track shifts, reports, and payforms for employees.
MIT License
23 stars 18 forks source link

Fix the test suite #281

Closed jasonkliu closed 10 years ago

jasonkliu commented 10 years ago

This is directly related to #276. It seems like we have more than a hundred tests available through running bundle exec rake, and I would like to get them all working so that we can enable continuous integration. I think some of them fail due to incorrect database configuration (perhaps on my own end), but there are definitely other issues here.

jasonkliu commented 10 years ago
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'db/shifts_test.announcements' doesn't exist: DELETE FROM `announcements`

Something along the lines of the test database isn't registering correctly. I added the anonymized database and I'm not sure what the issue is here.

RAILS_ENV=test bundle exec rake db:create db:migrate
RAILS_ENV=test bundle exec rake
jasonkliu commented 10 years ago

I should probably just rewrite all of the tests in rspec and see how it goes. It seems like we have both rake and rspec tests from about 7 months ago.

group :development, :test do
  gem 'rspec-rails', '~> 3.0.0'
  gem 'factory_girl_rails'
  gem 'annotate' # https://github.com/ctran/annotate_models add info headers
end
jasonkliu commented 10 years ago

Steps:

jasonkliu commented 10 years ago

I think someone messed up a migration a long time ago. I keep running into the issue:

     ActiveRecord::StatementInvalid:
       Mysql2::Error: Table 'db/shifts_test.user_sinks_user_sources' doesn't exist: DELETE FROM `user_sinks_user_sources`

The usual rake db:migrate db:test:prepare runs fine, but doesn't solve the issue. It might be here but it's unlikely....

db/migrate/20090625212551_create_user_sinks_user_sources.rb:3:    create_table :user_sinks_user_sources, :id => false do |t|
db/migrate/20090625212551_create_user_sinks_user_sources.rb:10:    drop_table :user_sinks_user_sources
db/migrate/20130617195919_drop_lsls_and_usus_tables.rb:4:    drop_table :user_sinks_user_sources
db/migrate/20130617195919_drop_lsls_and_usus_tables.rb:13:    create_table :user_sinks_user_sources do |t|

Removing the lines

fixtures :all
render_views

seems to solve it, but brings in a bunch more problems: there are tests for routes which don't exist.

shippy commented 10 years ago

Things to try:

  1. Recreate your schema. rm db/schema.rb && rake db:drop && rake db:migrate On Reservations, we ran into a bunch of issues after pull requests messed up the schema date; maybe that might be it.
  2. I wonder if you can make git bisect work by setting it on the specific test that's failing.

Getting rid of fixtures and replacing them with factories should be part of the plan, anyway, so nixing fixtures :all might be a good thing, assuming you have factories ready to replace them. render_views, on the other hand, is useful: in absence of specific view tests, it does the basic "does it compile?" test for views during controller specs, so the view code gets run at the very least. But you probably know that.

mnquintana commented 10 years ago

@shippy I think you should take this one over now

jasonkliu commented 10 years ago

Let me see if I can get it "running" first (rebase of 281), then @shippy can take it over.

https://github.com/YaleSTC/shifts/compare/281_fix_test_suite

Unfortunately it might be really hard to rebase, so I'm just going to re-branch and apply the commits

jasonkliu commented 10 years ago

I think this needs to be manually diagnosed; the compare above with the six commits made it work on the old rails-3.2 branch but these issues need to be manually troubleshooted on the "new" master branch.

mnquintana commented 10 years ago

Well one of the problems is that there isn't one test suite, there are 3 test suites: MiniTest, Cucumber, and RSpec

shippy commented 10 years ago

@jasonkliu Do you want to finish this issue, or should we take it over?

jasonkliu commented 10 years ago

@shippy I'll see if I can get this done by Saturday; otherwise you guys can take it over.

Thanks! :mushroom: :mushroom:

shippy commented 10 years ago

Closing this issue for now; remaining work is apportioned in separate issues (#373 for fixtures, TBD for old tests).