Skip to content

Commit 3908251

Browse files
committed
Use FactoryBot for Page creation
1 parent 1776cff commit 3908251

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

spec/jobs/pages/analyze_topics_job_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
RSpec.describe Pages::AnalyzeTopicsJob, type: :job do
44
describe "#perform" do
55
it "analyzes the topics of a page" do
6-
page = Page.find_or_create_by!(request_path: "/articles/custom-color-schemes-with-ruby-on-rails")
6+
page = FactoryBot.create(:page, request_path: "/articles/custom-color-schemes-with-ruby-on-rails")
77

88
response = {
99
id: "chatcmpl-ARm3zTYmf11ldAIJx9JywO8XjmKof",

spec/models/page_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
RSpec.describe Page, type: :model do
2121
it "represents a sitepress resource" do
22-
page = Page.find_or_create_by!(request_path: "/")
22+
page = FactoryBot.create(:page, request_path: "/")
2323

2424
expect(page.resource).to eq Sitepress.site.get("/")
2525
end

spec/models/topic_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
it "reject invalid topics" do
5656
topic = FactoryBot.create(:topic, :approved)
5757

58-
page = Page.find_or_create_by!(request_path: "/articles/custom-color-schemes-with-ruby-on-rails")
58+
page = FactoryBot.create(:page, request_path: "/articles/custom-color-schemes-with-ruby-on-rails")
5959

6060
page.topics = [topic]
6161

spec/requests/topics_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
RSpec.describe "Topics", type: :request do
44
describe "GET /index" do
55
it "returns http success" do
6-
article = Page.find_or_create_by!(request_path: "/articles/introducing-joy-of-rails")
6+
article = FactoryBot.create(:page, :published, request_path: "/articles/introducing-joy-of-rails")
77

88
topic_1 = FactoryBot.create(:topic, :approved)
99
topic_2 = FactoryBot.create(:topic, :approved)
@@ -21,7 +21,7 @@
2121

2222
describe "GET /show" do
2323
it "returns http success" do
24-
article = Page.find_or_create_by!(request_path: "/articles/introducing-joy-of-rails")
24+
article = FactoryBot.create(:page, :published, request_path: "/articles/introducing-joy-of-rails")
2525
topic = FactoryBot.create(:topic, :approved)
2626
article.topics << topic
2727

0 commit comments

Comments
 (0)