diff options
-rw-r--r-- | db/migrate/100_remove_redundant_raw_email_columns.rb | 6 | ||||
-rw-r--r-- | spec/models/outgoing_mailer_spec.rb | 17 | ||||
-rw-r--r-- | spec/spec_helper.rb | 16 |
3 files changed, 18 insertions, 21 deletions
diff --git a/db/migrate/100_remove_redundant_raw_email_columns.rb b/db/migrate/100_remove_redundant_raw_email_columns.rb index b8f9454f6..2ebffba34 100644 --- a/db/migrate/100_remove_redundant_raw_email_columns.rb +++ b/db/migrate/100_remove_redundant_raw_email_columns.rb @@ -1,11 +1,9 @@ class RemoveRedundantRawEmailColumns < ActiveRecord::Migration def self.up - ActiveRecord::Base.connection.execute("ALTER TABLE raw_emails DROP COLUMN data_text") - ActiveRecord::Base.connection.execute("ALTER TABLE raw_emails DROP COLUMN data_binary") + remove_column :raw_emails, :data_text end - def self.down - raise "safer not to have reverse migration scripts, and we never use them" + add_column :raw_emails, :data_text, :text end end diff --git a/spec/models/outgoing_mailer_spec.rb b/spec/models/outgoing_mailer_spec.rb index 83da7a553..24143fc9b 100644 --- a/spec/models/outgoing_mailer_spec.rb +++ b/spec/models/outgoing_mailer_spec.rb @@ -6,23 +6,6 @@ describe OutgoingMailer, " when working out follow up addresses" do # mocks. Put parts of the tests in spec/lib/tmail_extensions.rb fixtures :info_requests, :incoming_messages, :raw_emails, :public_bodies, :public_body_translations - before do - # XXX this is a hack around the fact that our raw_email model - # is in transition to something that doesn't actually live in - # the database at all. The raw_email fixture saves to the - # model, the model then needs to be told to save itself on the - # filesystem. - raw_email = raw_emails(:useless_raw_email) - raw_email.data=raw_email.dbdata - end - - after do - # And this is a hack around the fact that Rails fixtures don't - # have teardowns happen on them; we need to ensure no emails - # are left lying around - raw_emails(:useless_raw_email).destroy_file_representation! - end - it "should parse them right" do ir = info_requests(:fancy_dog_request) im = ir.incoming_messages[0] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bbcc9aa23..086def32a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,6 +30,22 @@ Spec::Runner.configure do |config| # in your config/boot.rb config.fixture_path = RAILS_ROOT + '/spec/fixtures/' + + config.before(:each) do + # XXX this is a hack around the fact that our raw_email model + # is in transition to something that doesn't actually live in + # the database at all. The raw_email *fixture* saves to the + # model, the model then needs to be told to save itself on the + # filesystem. + begin + raw_email = raw_emails(:useless_raw_email) + raw_email.data=raw_email.dbdata + rescue NoMethodError + # only do it in tests with raw_emails fixtures + end + end + + # == Fixtures # # You can declare fixtures for each example_group like this: |