1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activestorage/test/models/strict_loading_test.rb
2020-11-16 22:09:15 +08:00

29 lines
754 B
Ruby

# frozen_string_literal: true
require "test_helper"
require "database/setup"
class ActiveStorage::StrictLoadingTest < ActiveSupport::TestCase
class Admin < User
has_one_attached :image, strict_loading: true
has_many_attached :images, strict_loading: true
end
setup do
Admin.create!(name: "David")
end
test "has_one_attached raises if strict loading and lazy loading" do
assert_raises ActiveRecord::StrictLoadingViolationError do
admins = Admin.all
admins.as_json(include: :image)
end
end
test "has_many_attached raises if strict loading and lazy loading" do
assert_raises ActiveRecord::StrictLoadingViolationError do
admins = Admin.all
admins.as_json(include: :images)
end
end
end