docbrown/spec/requests/articles_update_spec.rb
rhymes e588fa7ece Code cleanups (#659)
* Initial automatic cleanup with rubocop

* Fix syntax error introduced by rubocop

* Cleanup seeds file

* Cleanup lib folder

* Exclude bin folder because it contains auto generated files

* Make Rubocop a little bit more chatty

* Block length should not include comments in the count

* Cleanup config folder

* Cleanup specs

* Updated Rubocop version and generated a todo file

* Fix broken ArticlesApi spec

* Fix tests

* Restored rubocop pre-commit hook
2018-08-07 11:00:13 -04:00

42 lines
1.3 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
# rubocop:disable RSpec/ExampleLength
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
# rubocop:enable RSpec/ExampleLength
end