Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Feature - added percentage and action type attributes #1507

Merged
merged 9 commits into from Sep 23, 2019

Conversation

shivashankar-f22labs
Copy link
Contributor

# So for page which has petition and followup as donation
# the page is considered as petition page.
def donation_page?
plugin_names.include?('fundraiser') && !plugin_names.include?('petition')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about just using plugins.first.is_a?(Plugins::Fundraiser)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osahyoun
Seems promising. Will update the code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osahyoun
Is there a chance fundraiser is created first before petition plugin?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I don't think so.

describe '#donation_page?' do
before do
@page = create :page # , liquid_layout: donation
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, we use the helper method, let.

let(:page) { create(:page) }

end

it 'should return false' do
[create(:plugins_petition, page: @page),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these statements in an array?


it 'should return false' do
[create(:call_tool, page: @page)]
expect(@page.donation_page?).to be_falsey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be_falsey is the wrong matcher. I think you'll want to use to be false, as the method returns a boolean.

@@ -135,6 +135,17 @@ def image_to_display
primary_image || images.first
end

def plugin_thermometers
plugins.collect do |x|
x if ['Plugins::ActionsThermometer', 'Plugins::DonationsThermometer'].include?(x.class.to_s)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use kind_of? or is_a?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osahyoun
does using member? is fine?
[Plugins::ActionsThermometer, Plugins::DonationsThermometer].member?(x.class)

if we use kind_of? and Is_a? it ends
Plugins::ActionsThermometer.is_a?(x.class) || Plugins::DonationsThermometer.is_a?(x.class)
Shall I use the member? or using the || operator?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


def plugin_thermometer_data
thermometer = donation_page? ? 'DonationsThermometer' : 'ActionsThermometer'
plugin_thermometers.select { |x| x.type == thermometer }.first.try(:liquid_data) || {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above (is_a? or kind_of?)

@osahyoun
Copy link
Member

💯 looks good. just a few minor comments on style.

@osahyoun osahyoun self-assigned this Sep 23, 2019
@shivashankar-f22labs shivashankar-f22labs merged commit c23d3fd into development Sep 23, 2019
@shivashankar-f22labs shivashankar-f22labs deleted the feature/add-plugin-info branch September 24, 2019 07:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants