Skip to content

Instantly share code, notes, and snippets.

@holderbaum
Created July 8, 2011 17:33
Show Gist options
  • Save holderbaum/1072331 to your computer and use it in GitHub Desktop.
Save holderbaum/1072331 to your computer and use it in GitHub Desktop.
mysql> select * from printings;
+-----------+-------------+------------+---------------------+---------------------+
| id | magazine_id | edition_id | created_at | updated_at |
+-----------+-------------+------------+---------------------+---------------------+
| 298486374 | NULL | NULL | 2011-07-08 17:28:06 | 2011-07-08 17:28:06 |
| 980190962 | NULL | NULL | 2011-07-08 17:28:06 | 2011-07-08 17:28:06 |
+-----------+-------------+------------+---------------------+---------------------+
require 'test_helper'
class PrintingTest < ActiveSupport::TestCase
# test "valid factory" do
# assert Factory.build(:printing).valid?, "Printing factory shouldn't be invalid"
# end
#
# test "invalid factory" do
# assert !Factory.build(:printing, :magazine => nil).valid?, "Printing without magazine shouldn't be valid"
# assert !Factory.build(:printing, :edition => nil).valid?, "Printing without edition shouldn't be valid"
# end
#
# test "should not create printing if magazine not exist" do
# edition = Factory.create :edition
# Printing.update_by_parsed_row(Factory.build :parsed_row, :edition => (Factory.build :parsed_edition, :name => edition.name, :id => edition.old_edition_id))
# assert_equal 0, Printing.count
# end
#
# test "should not create printing if edition not exist" do
# magazine = Factory.create :magazine
# Printing.update_by_parsed_row(Factory.build :parsed_row, :magazine => (Factory.build :parsed_magazine, :name => magazine.name, :id => magazine.old_magazine_id))
# assert_equal 0, Printing.count
# end
#
# test "should create a printing if magazine and edition exist" do
# magazine = Factory.create :magazine
# edition = Factory.create :edition
# Printing.update_by_parsed_row(Factory.build :parsed_row, :magazine => (Factory.build :parsed_magazine, :name => magazine.name, :id => magazine.old_magazine_id), :edition => (Factory.create :parsed_edition, :name => edition.name, :id => edition.old_edition_id))
#
# assert_equal 1, Printing.count
# assert_equal Magazine.first, Printing.first.magazine
# assert_equal Edition.first, Printing.first.edition
# end
#
# test "update_by_parsed_row should return nil if printing is invalid" do
# assert_nil Printing.update_by_parsed_row(Factory.build :parsed_row, :magazine => (Factory.build :parsed_magazine, :name => nil))
# end
puts "before: #{Printing.count}"
test "do something" do
puts "after: #{Printing.count}"
end
end
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment