Skip to content

Commit

Permalink
debugging admin option view
Browse files Browse the repository at this point in the history
  • Loading branch information
rnickles committed Mar 6, 2024
1 parent fb1a074 commit b169a03
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/views/options/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
.col-md-4.text-right
%label.col-form-label Allow Monthly Recurring Donations
= option_description_for(:allow_recurring_donations)
.col-md-8
.col-md-8{id:"allow_recurring_donations_select"}
= f.select :allow_recurring_donations, [['Yes', true], ['No', false]], {}, {:class => 'form-control', onchange: 'showDefaultDonation(this)'}
.form-row{id:"default_donation_type_form_row", style:"visibility: #{@o.allow_recurring_donations ? 'visible' : 'hidden'}"}
.col-md-4.text-right
Expand Down
20 changes: 9 additions & 11 deletions features/donations/monthly_donation_admin_view.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ Background:

Scenario: Allow Monthly Recurring Donations
When I set "allow_recurring_donations" to "Yes"
And I press "Update Settings"
And I should see "Update successful"
Then the radio button to select the default donation type should be "visible"
When I go to the donation default page
Then I should see "frequency"

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 set to "one"
And I press "Update Settings"
Then the radio button to select the default donation type should be "hidden"
When I go to the donation default page
Then I should not see "frequency"
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"
24 changes: 22 additions & 2 deletions features/step_definitions/option_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,31 @@
elsif value == 'No'
value = false
end
option = Option.find(1)
option.update_attribute(setting_name.parameterize.underscore.to_sym, value)
# puts Option.find(1).read_attribute(:allow_recurring_donations)
# option = Option.find(1)
# option.update_attribute(setting_name.parameterize.underscore.to_sym, value)
Option.first.update_attributes!(setting_name.parameterize.underscore.to_sym => value)


# recurring_donation_select = page.find(:css, "#allow_recurring_donations_select")
# recurring_donation_select.click
# byebug
# puts recurring_donation_select.find(:xpath, 'Yes')
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
# puts Option.find(1).read_attribute(:allow_recurring_donations)
# radio = page.find(:css, "#default_donation_type_form_row", visible: false)
expect(page).to have_selector('#default_donation_type_form_row', visible: true)
end

Then /the radio button to select the default donation type should be set to "(.*)"/ do |value|
# puts page.find(:css, '#default_donation_type_form_row')
expect(page).to have_css('#default_donation_type_form_row', visible: value)
end

0 comments on commit b169a03

Please sign in to comment.