diff --git a/spec/example_app/app/models/customer.rb b/spec/example_app/app/models/customer.rb index 01179863ec..e554141f33 100644 --- a/spec/example_app/app/models/customer.rb +++ b/spec/example_app/app/models/customer.rb @@ -4,7 +4,8 @@ class Customer < ApplicationRecord :territory, class_name: "Country", foreign_key: :country_code, - primary_key: :code + primary_key: :code, + optional: true ) has_many :log_entries, as: :logeable @@ -12,7 +13,7 @@ class Customer < ApplicationRecord validates :email, presence: true if Rails.gem_version >= Gem::Version.new("7.0") - enum :kind, {"standard" => "kind:std", "vip" => "kind:vip"} + enum :kind, {"standard" => "kind:std", "vip" => "kind:vip"}, default: "standard" else enum kind: {"standard" => "kind:std", "vip" => "kind:vip"} end diff --git a/spec/example_app/config/application.rb b/spec/example_app/config/application.rb index efe638b361..5e6fd5529a 100644 --- a/spec/example_app/config/application.rb +++ b/spec/example_app/config/application.rb @@ -14,6 +14,7 @@ module AdministratePrototype class Application < Rails::Application + config.load_defaults "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" config.i18n.enforce_available_locales = true config.generators do |generate| @@ -27,9 +28,9 @@ class Application < Rails::Application end config.action_controller.action_on_unpermitted_parameters = :raise - config.active_record.time_zone_aware_types = %i[datetime time] - config.active_support.to_time_preserves_timezone = :zone - config.action_view.form_with_generates_ids = true + if Rails.gem_version < Gem::Version.new("7.0") + config.active_support.to_time_preserves_timezone = :zone + end # Opt-out of FLoC: https://amifloced.org/ config.action_dispatch diff --git a/spec/example_app/db/seeds.rb b/spec/example_app/db/seeds.rb index eeef441109..4d6c7b271b 100644 --- a/spec/example_app/db/seeds.rb +++ b/spec/example_app/db/seeds.rb @@ -32,6 +32,7 @@ name: name, email: Faker::Internet.email(name: name), territory: countries.sample, + kind: ["standard", "vip"].sample, example_time: Faker::Time.between(from: "00:00:00", to: "23:59:59"), password: Faker::Internet.password } diff --git a/spec/example_app/spec/features/pagination_spec.rb b/spec/example_app/spec/features/pagination_spec.rb index e922649d91..7153966292 100644 --- a/spec/example_app/spec/features/pagination_spec.rb +++ b/spec/example_app/spec/features/pagination_spec.rb @@ -71,11 +71,11 @@ def expect_to_appear_in_order(*elements) context "with resources of type Page" do it "can paginate and sort" do - FactoryBot.create(:page, title: "Page 2") - FactoryBot.create(:page, title: "Page 4") - FactoryBot.create(:page, title: "Page 1") - FactoryBot.create(:page, title: "Page 5") - FactoryBot.create(:page, title: "Page 3") + create(:page, title: "Page 2") + create(:page, title: "Page 4") + create(:page, title: "Page 1") + create(:page, title: "Page 5") + create(:page, title: "Page 3") visit admin_pages_path(per_page: 3) click_on "Title" diff --git a/spec/factories.rb b/spec/factories.rb index 8086b679d4..7e9334f794 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -43,11 +43,14 @@ image_url do "https://cdn.recombu.com/mobile/images/news/M11370/1264769196_w670.jpg" end - product_meta_tag + trait :with_product_meta_tag do + association :product_meta_tag + end release_year { [2018, 2019, 2020].sample } end factory :product_meta_tag do + association :product meta_title { "meta_title" } meta_description { "meta_description" } end @@ -78,5 +81,9 @@ name { Faker::Internet.ip_v4_address } end - factory :page + factory :page do + sequence(:title) { |n| "Page #{n}" } + body { "Sample body text" } + association :product + end end diff --git a/spec/features/products_form_spec.rb b/spec/features/products_form_spec.rb index fcc7a11161..e22980bf7a 100644 --- a/spec/features/products_form_spec.rb +++ b/spec/features/products_form_spec.rb @@ -60,7 +60,7 @@ end it "edits product and meta tag data correctly", js: true do - product = create(:product, banner: <<~HTML) + product = create(:product, :with_product_meta_tag, banner: <<~HTML)