Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions spec/example_app/app/models/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ 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

validates :name, presence: true
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
Expand Down
7 changes: 4 additions & 3 deletions spec/example_app/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/example_app/db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions spec/example_app/spec/features/pagination_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 9 additions & 2 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/features/products_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<div>A banner with a <a href="https://example.com">link</a>.</div>
HTML

Expand Down
Loading