Sha256: 3e3a65693e85e83f9c8433de4b6cf9fae3d3180610e151ca8c3091377b31fb98
Contents?: true
Size: 1.82 KB
Versions: 13
Compression:
Stored size: 1.82 KB
Contents
# frozen_string_literal: true require "spec_helper" module Decidim module Proposals describe ProposalVote do let!(:organization) { create(:organization) } let!(:feature) { create(:feature, organization: organization, manifest_name: "proposals") } let!(:participatory_process) { create(:participatory_process, organization: organization) } let!(:author) { create(:user, organization: organization) } let!(:proposal) { create(:proposal, feature: feature, author: author) } let!(:proposal_vote) { create(:proposal_vote, proposal: proposal, author: author) } subject { proposal_vote } it "is valid" do expect(proposal_vote).to be_valid end it "has an associated author" do expect(proposal_vote.author).to be_a(Decidim::User) end it "has an associated proposal" do expect(proposal_vote.proposal).to be_a(Decidim::Proposals::Proposal) end it "validates uniqueness for author and proposal combination" do expect do create(:proposal_vote, proposal: proposal, author: author) end.to raise_error(ActiveRecord::RecordInvalid) end context "when no author" do before do proposal_vote.author = nil end it { is_expected.to be_invalid } end context "when no proposal" do before do proposal_vote.proposal = nil end it { is_expected.to be_invalid } end context "when proposal and author have different organization" do let(:other_author) { create(:user) } let(:other_proposal) { create(:proposal) } it "is invalid" do proposal_vote = build(:proposal_vote, proposal: other_proposal, author: other_author) expect(proposal_vote).to be_invalid end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems