docbrown/spec/requests/articles_update_spec.rb
Tim Lange 3494264404 Enabled rubocop/lint (#2130)
* WIP: Enabled rubocop/lint

* FIX: Fixed failing test

* FIX: Small change to return

* FIX: Changed indent
2019-03-21 10:53:44 -04:00

40 lines
1.2 KiB
Ruby

require "rails_helper"
RSpec.describe "ArticlesUpdate", type: :request do
let(:user) { create(:user) }
let(:article) { create(:article, user_id: user.id) }
before do
sign_in user
end
it "updates ordinary article with proper params" do
new_title = "NEW TITLE #{rand(100)}"
put "/articles/#{article.id}", params: {
article: { title: new_title, body_markdown: "Yo ho ho#{rand(100)}", tag_list: "yo" }
}
expect(Article.last.title).to eq(new_title)
end
it "does not create a job opportunity if no hiring tag" do
new_title = "NEW TITLE #{rand(100)}"
put "/articles/#{article.id}", params: {
article: {
title: new_title, body_markdown: "Yo ho ho#{rand(100)}", tag_list: "yo",
job_opportunity: { remoteness: "on_premise" }
}
}
expect(JobOpportunity.count).to eq(0)
end
it "updates ordinary article with job opportunity nested" do
new_title = "NEW TITLE #{rand(100)}"
put "/articles/#{article.id}", params: {
article: {
title: new_title, body_markdown: "Yo ho ho#{rand(100)}", tag_list: "hiring",
job_opportunity: { remoteness: "on_premise" }
}
}
expect(Article.last.job_opportunity.remoteness).to eq("on_premise")
end
end