1
0
Fork 0

Implement method Person#party_member?

This commit is contained in:
Alex Kotov 2019-01-29 06:52:35 +05:00
parent 4252b1f214
commit 25c260c58f
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
5 changed files with 30 additions and 16 deletions

View file

@ -25,8 +25,4 @@ class MembershipApp < ApplicationRecord
self.organization_membership = nil if organization_membership.blank? self.organization_membership = nil if organization_membership.blank?
self.comment = nil if comment.blank? self.comment = nil if comment.blank?
end end
def resolved?
person&.related_to_party?
end
end end

View file

@ -14,16 +14,12 @@ class Person < ApplicationRecord
validate :supporter_since_not_in_future validate :supporter_since_not_in_future
validate :member_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? def party_supporter?
supporter_since.present? supporter_since.present?
end end
def party_member? def party_member?
true member_since.present?
end end
def excluded_from_party? def excluded_from_party?

View file

@ -1,7 +1,10 @@
<div class="container"> <div class="container">
<% if @membership_app.resolved? %> <% if @membership_app.person&.party_member? %>
<h1><%= translate '.congratulations' %></h1> <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 %> <% else %>
<h1><%= translate '.header' %></h1> <h1><%= translate '.header' %></h1>
<p class="lead"><%= translate '.lead_text' %></p> <p class="lead"><%= translate '.lead_text' %></p>

View file

@ -32,8 +32,6 @@ RSpec.describe MembershipApp do
it { is_expected.to validate_uniqueness_of :account_id } it { is_expected.to validate_uniqueness_of :account_id }
pending '#resolved?'
describe '#email' do describe '#email' do
def allow_value(*) def allow_value(*)
super.for :email super.for :email

View file

@ -20,9 +20,6 @@ RSpec.describe Person do
it { is_expected.not_to validate_presence_of :regional_office } it { is_expected.not_to validate_presence_of :regional_office }
pending '#related_to_party?'
pending '#party_supporter?'
pending '#party_member?'
pending '#excluded_from_party?' pending '#excluded_from_party?'
describe '#supporter_since' do describe '#supporter_since' do
@ -67,5 +64,29 @@ RSpec.describe Person do
specify { expect(result).to eq true } specify { expect(result).to eq true }
end 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
end end