aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRafael França <rafael@franca.dev>2019-07-27 21:12:06 -0400
committerGitHub <noreply@github.com>2019-07-27 21:12:06 -0400
commit481714dd0605a1e639cb6a60a2ea5aedf98cfe29 (patch)
treee75a2f50a7f7291502558b07ccfb6810a9e31980 /activerecord/test/cases
parent2e9176c04a9e167efc15f904fd52ab793a29b931 (diff)
parentc09a4fd23d7d52552132edde7ad155f366c560b8 (diff)
downloadrails-481714dd0605a1e639cb6a60a2ea5aedf98cfe29.tar.gz
rails-481714dd0605a1e639cb6a60a2ea5aedf98cfe29.tar.bz2
rails-481714dd0605a1e639cb6a60a2ea5aedf98cfe29.zip
Merge pull request #36303 from gaotongfei/feature/ignore-specified-fixtures
Allow specifying fixtures to be ignored in "_fixture" section
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/fixtures_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index a7f01e898e..7ad032a632 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -1279,6 +1279,33 @@ class CustomNameForFixtureOrModelTest < ActiveRecord::TestCase
end
end
+class IgnoreFixturesTest < ActiveRecord::TestCase
+ fixtures :other_books, :parrots
+
+ test "ignores books fixtures" do
+ assert_raise(StandardError) { other_books(:published) }
+ assert_raise(StandardError) { other_books(:published_paperback) }
+ assert_raise(StandardError) { other_books(:published_ebook) }
+
+ assert_equal 2, Book.count
+ assert_equal "Agile Web Development with Rails", other_books(:awdr).name
+ assert_equal "published", other_books(:awdr).status
+ assert_equal "paperback", other_books(:awdr).format
+ assert_equal "english", other_books(:awdr).language
+
+ assert_equal "Ruby for Rails", other_books(:rfr).name
+ assert_equal "ebook", other_books(:rfr).format
+ assert_equal "published", other_books(:rfr).status
+ end
+
+ test "ignores parrots fixtures" do
+ assert_raise(StandardError) { parrots(:DEFAULT) }
+ assert_raise(StandardError) { parrots(:DEAD_PARROT) }
+
+ assert_equal "DeadParrot", parrots(:polly).parrot_sti_class
+ end
+end
+
class FixturesWithDefaultScopeTest < ActiveRecord::TestCase
fixtures :bulbs