Skip to content

Commit 8aff034

Browse files
committed
Fix specs broken by load_defaults setting
1 parent 7199e7f commit 8aff034

5 files changed

Lines changed: 19 additions & 10 deletions

File tree

spec/example_app/app/models/customer.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ class Customer < ApplicationRecord
44
:territory,
55
class_name: "Country",
66
foreign_key: :country_code,
7-
primary_key: :code
7+
primary_key: :code,
8+
optional: true
89
)
910
has_many :log_entries, as: :logeable
1011

1112
validates :name, presence: true
1213
validates :email, presence: true
1314

1415
if Rails.gem_version >= Gem::Version.new("7.0")
15-
enum :kind, {"standard" => "kind:std", "vip" => "kind:vip"}
16+
enum :kind, {"standard" => "kind:std", "vip" => "kind:vip"}, default: "standard"
1617
else
1718
enum kind: {"standard" => "kind:std", "vip" => "kind:vip"}
1819
end

spec/example_app/db/seeds.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
name: name,
3333
email: Faker::Internet.email(name: name),
3434
territory: countries.sample,
35+
kind: ["standard", "vip"].sample,
3536
example_time: Faker::Time.between(from: "00:00:00", to: "23:59:59"),
3637
password: Faker::Internet.password
3738
}

spec/example_app/spec/features/pagination_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ def expect_to_appear_in_order(*elements)
7171

7272
context "with resources of type Page" do
7373
it "can paginate and sort" do
74-
FactoryBot.create(:page, title: "Page 2")
75-
FactoryBot.create(:page, title: "Page 4")
76-
FactoryBot.create(:page, title: "Page 1")
77-
FactoryBot.create(:page, title: "Page 5")
78-
FactoryBot.create(:page, title: "Page 3")
74+
create(:page, title: "Page 2")
75+
create(:page, title: "Page 4")
76+
create(:page, title: "Page 1")
77+
create(:page, title: "Page 5")
78+
create(:page, title: "Page 3")
7979

8080
visit admin_pages_path(per_page: 3)
8181
click_on "Title"

spec/factories.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@
4343
image_url do
4444
"https://cdn.recombu.com/mobile/images/news/M11370/1264769196_w670.jpg"
4545
end
46-
product_meta_tag
46+
trait :with_product_meta_tag do
47+
association :product_meta_tag
48+
end
4749
release_year { [2018, 2019, 2020].sample }
4850
end
4951

5052
factory :product_meta_tag do
53+
association :product
5154
meta_title { "meta_title" }
5255
meta_description { "meta_description" }
5356
end
@@ -78,5 +81,9 @@
7881
name { Faker::Internet.ip_v4_address }
7982
end
8083

81-
factory :page
84+
factory :page do
85+
sequence(:title) { |n| "Page #{n}" }
86+
body { "Sample body text" }
87+
association :product
88+
end
8289
end

spec/features/products_form_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
end
6161

6262
it "edits product and meta tag data correctly", js: true do
63-
product = create(:product, banner: <<~HTML)
63+
product = create(:product, :with_product_meta_tag, banner: <<~HTML)
6464
<div>A banner with a <a href="https://example.com">link</a>.</div>
6565
HTML
6666

0 commit comments

Comments
 (0)