adds spec
checks failed debate create/update and inclusion of featured tags
This commit is contained in:
@@ -71,6 +71,27 @@ feature 'Debates' do
|
|||||||
expect(page).to have_content "Debate was successfully created."
|
expect(page).to have_content "Debate was successfully created."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'Failed creation goes back to new showing featured tags' do
|
||||||
|
featured_tag = create(:tag, :featured)
|
||||||
|
tag = create(:tag)
|
||||||
|
login_as(create(:user))
|
||||||
|
|
||||||
|
visit new_debate_path
|
||||||
|
fill_in 'debate_title', with: ""
|
||||||
|
fill_in 'debate_description', with: 'Very important issue...'
|
||||||
|
fill_in 'debate_captcha', with: correct_captcha_text
|
||||||
|
check 'debate_terms_of_service'
|
||||||
|
|
||||||
|
click_button "Create Debate"
|
||||||
|
|
||||||
|
expect(page).to_not have_content "Debate was successfully created."
|
||||||
|
expect(page).to have_content "1 error"
|
||||||
|
within(".tags") do
|
||||||
|
expect(page).to have_content featured_tag.name
|
||||||
|
expect(page).to_not have_content tag.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'JS injection is prevented but safe html is respected' do
|
scenario 'JS injection is prevented but safe html is respected' do
|
||||||
author = create(:user)
|
author = create(:user)
|
||||||
login_as(author)
|
login_as(author)
|
||||||
@@ -201,6 +222,27 @@ feature 'Debates' do
|
|||||||
expect(page).to have_content "Debate was successfully updated."
|
expect(page).to have_content "Debate was successfully updated."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'Failed update goes back to edit showing featured tags' do
|
||||||
|
debate = create(:debate)
|
||||||
|
featured_tag = create(:tag, :featured)
|
||||||
|
tag = create(:tag)
|
||||||
|
login_as(debate.author)
|
||||||
|
|
||||||
|
visit edit_debate_path(debate)
|
||||||
|
expect(current_path).to eq(edit_debate_path(debate))
|
||||||
|
|
||||||
|
fill_in 'debate_title', with: ""
|
||||||
|
fill_in 'debate_captcha', with: correct_captcha_text
|
||||||
|
click_button "Update Debate"
|
||||||
|
|
||||||
|
expect(page).to_not have_content "Debate was successfully updated."
|
||||||
|
expect(page).to have_content "1 error"
|
||||||
|
within(".tags") do
|
||||||
|
expect(page).to have_content featured_tag.name
|
||||||
|
expect(page).to_not have_content tag.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'Limiting tags shown' do
|
describe 'Limiting tags shown' do
|
||||||
let(:all_tags) {
|
let(:all_tags) {
|
||||||
["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
|
["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
|
||||||
|
|||||||
Reference in New Issue
Block a user