Implement method Person#party_member?
This commit is contained in:
parent
4252b1f214
commit
25c260c58f
5 changed files with 30 additions and 16 deletions
|
@ -25,8 +25,4 @@ class MembershipApp < ApplicationRecord
|
|||
self.organization_membership = nil if organization_membership.blank?
|
||||
self.comment = nil if comment.blank?
|
||||
end
|
||||
|
||||
def resolved?
|
||||
person&.related_to_party?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,16 +14,12 @@ class Person < ApplicationRecord
|
|||
validate :supporter_since_not_in_future
|
||||
validate :member_since_not_in_future
|
||||
|
||||
def related_to_party?
|
||||
party_supporter? || party_member? || excluded_from_party?
|
||||
end
|
||||
|
||||
def party_supporter?
|
||||
supporter_since.present?
|
||||
end
|
||||
|
||||
def party_member?
|
||||
true
|
||||
member_since.present?
|
||||
end
|
||||
|
||||
def excluded_from_party?
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<div class="container">
|
||||
<% if @membership_app.resolved? %>
|
||||
<% if @membership_app.person&.party_member? %>
|
||||
<h1><%= translate '.congratulations' %></h1>
|
||||
<p class="lead"><%= translate '.lead_congratulations' %></p>
|
||||
<p class="lead"><%= translate '.lead_congratulations_member' %></p>
|
||||
<% elsif @membership_app.person&.party_supporter? %>
|
||||
<h1><%= translate '.congratulations' %></h1>
|
||||
<p class="lead"><%= translate '.lead_congratulations_supporter' %></p>
|
||||
<% else %>
|
||||
<h1><%= translate '.header' %></h1>
|
||||
<p class="lead"><%= translate '.lead_text' %></p>
|
||||
|
|
|
@ -32,8 +32,6 @@ RSpec.describe MembershipApp do
|
|||
|
||||
it { is_expected.to validate_uniqueness_of :account_id }
|
||||
|
||||
pending '#resolved?'
|
||||
|
||||
describe '#email' do
|
||||
def allow_value(*)
|
||||
super.for :email
|
||||
|
|
|
@ -20,9 +20,6 @@ RSpec.describe Person do
|
|||
|
||||
it { is_expected.not_to validate_presence_of :regional_office }
|
||||
|
||||
pending '#related_to_party?'
|
||||
pending '#party_supporter?'
|
||||
pending '#party_member?'
|
||||
pending '#excluded_from_party?'
|
||||
|
||||
describe '#supporter_since' do
|
||||
|
@ -67,5 +64,29 @@ RSpec.describe Person do
|
|||
|
||||
specify { expect(result).to eq true }
|
||||
end
|
||||
|
||||
context 'for party member' do
|
||||
subject { create :member_person }
|
||||
|
||||
specify { expect(result).to eq true }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#party_member?' do
|
||||
let(:result) { subject.party_member? }
|
||||
|
||||
specify { expect(result).to eq false }
|
||||
|
||||
context 'for party supporter' do
|
||||
subject { create :supporter_person }
|
||||
|
||||
specify { expect(result).to eq false }
|
||||
end
|
||||
|
||||
context 'for party member' do
|
||||
subject { create :member_person }
|
||||
|
||||
specify { expect(result).to eq true }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Reference in a new issue