Skip to content

Commit

Permalink
New Branch Robbie and Pratyush made
Browse files Browse the repository at this point in the history
  • Loading branch information
PratyushSharma14 committed Mar 14, 2024
1 parent 6f206cb commit c9a77c7
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
23 changes: 23 additions & 0 deletions features/donations/monthly_donation_admin_view.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@javascript
Feature: allow recurring donations
As an admin
So that customers can setup recurring donations
I want to allow recurring donations

Background:
Given I am logged in as administrator
And I visit the admin:settings page

Scenario: Allow Monthly Recurring Donations
When I set allow recurring donations to "Yes"
Then the radio button to select the default donation type should be "visible"
Then the radio button to select the default donation type should be set to "one"
And I press "Update Settings"
Then I should see "Update successful"

Scenario: Disallow Monthly Recurring Donations
When I visit the admin:settings page
And I set allow recurring donations to "No"
Then the radio button to select the default donation type should be "hidden"
And I press "Update Settings"
Then I should see "Update successful"
16 changes: 16 additions & 0 deletions features/donations/monthly_donation_user_view.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Feature: make a recurring donation through quick donation

Background:
Given I am logged in as customer "Tom Foolery"
Given admin has allowed recurring donations
Given admin "has" allowed recurring donations
And I go to the quick donation page

@stubs_successful_credit_card_payment
Scenario: make donation
Then I should see "frequency"
When I select monthly in the donation frequency radio button
When I fill in "Donation amount" with "15"
And I press "Charge Donation to Credit Card"
Then I should see "You have paid a total of $15.00 by Credit card"
Then there should be a Recurring Donation model instance belonging to "Tom Foolery"
43 changes: 43 additions & 0 deletions features/step_definitions/option_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,46 @@
Then /^the setting "(.*)" should be "(.*)"$/ do |opt,val|
expect(Option.send(opt.tr(' ','').underscore)).to eq(val)
end

#####
# Step defintions for testing the recurring donation feature admin view
#####
When /I set allow recurring donations to "(.*)"/ do |value|
drop_down = page.find(:css, "#allow_recurring_donations_select")
drop_down.select(value)
end
Then /the radio button to select the default donation type should be "(.*)"/ do |value|
if value == 'visible'
value = true
elsif value == 'hidden'
value = false
end
expect(page).to have_selector('#default_donation_type_form_row', visible: value)
end
Then /the radio button to select the default donation type should be set to "(.*)"/ do |value|
# How to check what option the radio button currently has selected?
radio_button = page.find(:css, '#donation_type_radio')
end

######
# Step defintions for testing the recurring donation feature user view
######

Given /admin "(.*)" allowed recurring donations/ do |value|
if value == 'has'
value = true
elsif value == 'has not'
value = false
end
Option.first.update_attributes!(:allow_recurring_donations => value)
end
When /I select monthly in the donation frequency radio button/ do
radio_button = page.find(:css, "#donation_frequency_radio")
radio_button.choose("Monthly")
end
Then /there should be a Recurring Donation model instance belonging to "(.*) (.*)"$/ do |first,last|
r = RecurringDonation.first
c = Customer.find(r.customer_id)
expect(c.first_name).to eq(first)
expect(c.last_name).to eq(last)
end

0 comments on commit c9a77c7

Please sign in to comment.