Skip to content

Instantly share code, notes, and snippets.

@GCorbel
Last active March 13, 2018 13:38
Show Gist options
  • Save GCorbel/513417c2cf856db594e53dcf7cf21ead to your computer and use it in GitHub Desktop.
Save GCorbel/513417c2cf856db594e53dcf7cf21ead to your computer and use it in GitHub Desktop.
it 'updates categories' do
expect {
put :update_categories, id: contents(:adsl_cancel_question).id, category_ids: [categories(:mobile).id, categories(:technical).id], thread_id: content_threads(:adsl_cancel).id
}.to change { contents(:adsl_cancel_question).reload.categories.to_a.sort }.from(array_including([categories(:internet), categories(:sales)])).to(array_including([categories(:technical), categories(:mobile)]))
end
# Variables created with let are shared accross all tests
let(:content) { contents(:adsl_cancel_question).set(intervention: nil) }
let(:category_mobile) { categories(:mobile) }
let(:category_technical) { categories(:technical) }
let(:category_internet) { categories(:internet) }
let(:category_sales) { categories(:sales) }
let(:category_departement) { categories(:department) }
let(:thread) { content_threads(:adsl_cancel) }
it 'updates categories' do
expect {
put :update_categories,
id: content.id,
category_ids: [category_mobile.id, category_technical.id],
thread_id: thread.id
}.to change {
content.reload.categories.to_a.sort
}.from(array_including([category_internet, category_sales]))
.to(array_including([category_technical, category_mobile]))
end
# Variables created with let are shared accross all tests
let(:content) { contents(:adsl_cancel_question).set(intervention: nil) }
let(:category_mobile) { categories(:mobile) }
let(:category_technical) { categories(:technical) }
let(:category_internet) { categories(:internet) }
let(:category_sales) { categories(:sales) }
let(:category_departement) { categories(:department) }
let(:thread) { content_threads(:adsl_cancel) }
it 'updates categories' do
expect(content.categories).to include(category_internet, category_sales)
put :update_categories,
id: content.id,
category_ids: [category_mobile.id, category_technical.id],
thread_id: thread.id
expect(content.reload.categories.to_a).to include(category_mobile, category_technical)
end
it 'updates categories' do
expect {
put :update_categories,
id: contents(:adsl_cancel_question).id,
category_ids: [categories(:mobile).id, categories(:technical).id],
thread_id: content_threads(:adsl_cancel).id
}.to change {
contents(:adsl_cancel_question).reload.categories.to_a.sort
}.from(array_including([categories(:internet), categories(:sales)]))
.to(array_including([categories(:technical), categories(:mobile)]))
end
it 'updates categories' do
expect(contents(:adsl_cancel_question)).to include(categories(:internet), categories(:sales))
put :update_categories,
id: contents(:adsl_cancel_question).id,
category_ids: [categories(:mobile).id, categories(:technical).id],
thread_id: content_threads(:adsl_cancel).id
expect(contents(:adsl_cancel_question).reload.categories.to_a)
.to include(categories(:technical), categories(:mobile))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment