adds specs

This commit is contained in:
rgarcia
2016-12-21 18:46:38 +01:00
parent 675081141c
commit 0deba76db1
2 changed files with 181 additions and 58 deletions

View File

@@ -1,3 +1,5 @@
require 'rails_helper'
feature 'Signature sheets' do
background do
@@ -5,31 +7,61 @@ feature 'Signature sheets' do
login_as(admin.user)
end
scenario "Index"
scenario "Index" do
3.times { create(:signature_sheet) }
scenario 'Create' do
visit admin_path
visit admin_signature_sheets_path
click_link 'Signature Sheets'
click_link 'New'
expect(page).to have_css(".signature_sheet", count: 3)
select "Proposal", from: "signable_type"
fill_in "signable_id", with: "1"
fill_in "document_numbers", with: "12345678Z, 99999999Z"
click_button "Save"
expect(page).to have_content "Signature sheet saved successfully"
SignatureSheet.all.each do |signature_sheet|
expect(page).to have_content signature_sheet.name
end
end
scenario 'Errors on create'
scenario 'Create' do
proposal = create(:proposal)
visit new_admin_signature_sheet_path
select "Citizen proposal", from: "signature_sheet_signable_type"
fill_in "signature_sheet_signable_id", with: proposal.id
fill_in "signature_sheet_document_numbers", with: "12345678Z, 99999999Z"
click_button "Create signature sheet"
expect(page).to have_content "Signature sheet created successfully"
end
scenario 'Errors on create' do
visit new_admin_signature_sheet_path
click_button "Create signature sheet"
expect(page).to have_content error_message
end
scenario 'Show' do
#display signable
#display created_at
#display author
#display valid signatures count
#display invalid signatures count
#display invalid signatures with their error
proposal = create(:proposal)
user = Administrator.first.user
signature_sheet = create(:signature_sheet,
signable: proposal,
document_numbers: "12345678Z, 123A, 123B",
author: user)
signature_sheet.verify_signatures
visit admin_signature_sheet_path(signature_sheet)
expect(page).to have_content "Citizen proposal #{proposal.id}"
expect(page).to have_content "12345678Z, 123A, 123B"
expect(page).to have_content signature_sheet.created_at.strftime("%d %b %H:%M")
expect(page).to have_content user.name
within("#verified_signatures") do
expect(page).to have_content 1
end
within("#unverified_signatures") do
expect(page).to have_content 2
end
end
end