diff --git a/spec/factories.rb b/spec/factories.rb index c53f16be6..19bfc952a 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -343,4 +343,12 @@ FactoryGirl.define do association :sender, factory: :user association :receiver, factory: :user end + + factory :signature_sheet do + + end + + factory :signature do + + end end diff --git a/spec/features/admin/signature_sheets_spec.rb b/spec/features/admin/signature_sheets_spec.rb new file mode 100644 index 000000000..3ba13d819 --- /dev/null +++ b/spec/features/admin/signature_sheets_spec.rb @@ -0,0 +1,35 @@ +feature 'Signature sheets' do + + background do + admin = create(:administrator) + login_as(admin.user) + end + + scenario "Index" + + scenario 'Create' do + visit admin_path + + click_link 'Signature Sheets' + click_link 'New' + + 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" + end + + scenario 'Errors on create' + + scenario 'Show' do + #display signable + #display created_at + #display author + #display valid signatures count + #display invalid signatures count + #display invalid signatures with their error + end + +end \ No newline at end of file diff --git a/spec/models/signature_sheet_spec.rb b/spec/models/signature_sheet_spec.rb new file mode 100644 index 000000000..2f956541c --- /dev/null +++ b/spec/models/signature_sheet_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' + +describe SignatureSheet do + + describe "validations" do + it "should be valid" + it "should not be valid without a valid signable" + it "should not be valid without document numbers" + it "should not be valid without an author" + end + + describe "name" do + it "returns name for proposal signature sheets" + it "returns name for spending proposal signature sheets" + end + + describe "verify_signatures" do + it "marks signature sheet as processed after verifing all document numbers" + end + + describe "invalid_signatures" do + it "returns invalid signatures" + it "does not return valid signatures" + end + + describe "parsed_document_numbers" do + it "returns an array after spliting document numbers by newlines" + end + +end \ No newline at end of file diff --git a/spec/models/signature_spec.rb b/spec/models/signature_spec.rb new file mode 100644 index 000000000..d1f37a3ec --- /dev/null +++ b/spec/models/signature_spec.rb @@ -0,0 +1,46 @@ +require 'rails_helper' + +describe Signature + + describe "validations" do + it "should be valid" + it "should be valid if user exists" + it "should not be valid if already voted" + it "should not be valid if not in census" + end + + describe "in census" do + it "checks for all document_types" + end + + describe "verify" do + + describie "valid" do + it "sets status to verified" + it "asigns vote to user" + end + + describe "invalid" + it "sets status to error" + it "does not asign any votes" + end + + end + + describe "assign vote" do + + describe "existing user" do + it "assigns vote to user" + it "does not assign vote to user if already voted" + it "marks the vote as coming from a signature" + end + + describe "inexistent user" do + it "creates a user with that document number" + it "assign the vote to newly created user" + it "marks the vote as coming from a signature" + end + + end + +end \ No newline at end of file