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

Commit

Permalink
Merge pull request #389 from SumOfUs/development
Browse files Browse the repository at this point in the history
release
  • Loading branch information
osahyoun committed Feb 24, 2016
2 parents 8deda59 + 90e2112 commit a91b007
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 89 deletions.
20 changes: 10 additions & 10 deletions app/assets/javascripts/layout_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ const setupOnce = require('setup_once');

showRelevantLayouts(e) {
const $target = $(e.target);
const layoutClasses = this.getLayoutClasses($target.attr('id'));
const layoutRows = $target.closest('.form-group').find(layoutClasses.inverse_class).not(layoutClasses.own_class);
let $allRows = $target.closest('.form-group').find('.radio-group__option');
if ($target.is(':checked')) {
layoutRows.removeClass('hidden');
$allRows.removeClass('hidden');
} else {
layoutRows.addClass('hidden');
const layoutClass = this.getLayoutClass($target.attr('id'));
$allRows.not(layoutClass).addClass('hidden');
}
},

getLayoutClasses(layout_select_id) {
if (layout_select_id==='primary') {
return {inverse_class: '.post-action-layout', own_class: '.primary-layout'}
} else if (layout_select_id==='follow-up') {
return {inverse_class: '.primary-layout', own_class: '.post-action-layout'}
getLayoutClass(layout_select_id) {
if (layout_select_id === 'primary') {
return '.primary-layout';
} else if (layout_select_id === 'follow-up') {
return '.post-action-layout';
}
}
},

});

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/tooltips.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function(){
$.subscribe("pages:edit form:edit", function(){
$.subscribe("pages:new pages:edit form:edit", function(){
$('[data-toggle="tooltip"]').tooltip()
});
}());
4 changes: 3 additions & 1 deletion app/liquid/views/layouts/post-donation-share.liquid
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% comment %} Description: A follow-up page thanking for donating money and asking to share {% endcomment %}

{% capture confirmation %}{{ 'fundraiser.confirmation' | t }}{% endcapture %}
{% capture message %}{{ 'fundraiser.thank_you' | t }}{% endcapture %}
{% include 'Share Page', message: message %}
{% include 'Share Page', message: message, confirmation: confirmation %}
{% include 'Simple Footer', extra_class: 'simple-footer--stuck-to-bottom' %}
3 changes: 2 additions & 1 deletion app/liquid/views/layouts/post-petition-share.liquid
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% comment %} Description: A follow-up page thanking for signing a petition and asking to share {% endcomment %}

{% capture confirmation %}{{ 'petition.confirmation' | t }}{% endcapture %}
{% capture message %}{{ 'petition.thank_you' | val: 'petition_title', title | t }}{% endcapture %}
{% include 'Share Page', message: message %}
{% include 'Share Page', message: message, confirmation: confirmation %}
{% include 'Simple Footer', extra_class: 'simple-footer--stuck-to-bottom' %}
2 changes: 1 addition & 1 deletion app/liquid/views/partials/_share_page.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<div class="center-content__central-square">

<div class='thank-you__action-confirmation'>{{ 'petition.confirmation' | t }}</div>
<div class='thank-you__action-confirmation'>{{ confirmation }}</div>
<h1 class="thank-you__thanks">{{ message }}</h1>
<div class="thank-you__cta">{{ 'share.cta' | t }}</div>

Expand Down
3 changes: 3 additions & 0 deletions app/models/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ class Member < ActiveRecord::Base
has_one :customer, class_name: "Payment::BraintreeCustomer"
has_paper_trail on: [:update, :destroy]

validates :email, uniqueness: true, allow_nil: true
before_save { self.email.try(:downcase!) }

def self.find_from_request(akid: nil, id: nil)
if akid.present?
actionkit_user_id = AkidParser.parse(akid)[:actionkit_user_id]
Expand Down
7 changes: 2 additions & 5 deletions app/services/action_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def member

@user.assign_attributes(
filtered_params.tap do |data|
data[:actionkit_user_id] = actionkit_user_id(@params[:akid]) if @params.has_key?(:akid)
id = AkidParser.parse(@params[:akid])[:actionkit_user_id]
data[:actionkit_user_id] = id unless id.blank?
end
)

Expand All @@ -64,9 +65,5 @@ def permitted_keys
def page
@page ||= Page.find(@params[:page_id])
end

def actionkit_user_id(akid)
AkidParser.parse(akid)[:actionkit_user_id]
end
end

1 change: 1 addition & 0 deletions app/services/action_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def user_data
last_name: member.last_name,
email: member.email,
country: member.country,
akid: data[:akid],
postal: data[:postal],
address1: data[:address1],
source: data[:source]
Expand Down
4 changes: 2 additions & 2 deletions app/views/pages/new.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
= render 'shared/error_messages', target: @page

.form-group
= f.label :title, t('.title_label')
= label_with_tooltip(f, :title, t('pages.edit.title'), t('tooltips.title'))
= f.text_field :title, class: 'form-control'

.form-group.slug-field style='display:none;'
Expand All @@ -30,7 +30,7 @@
= f.select :language_id, Language.all.map { |lang| [lang.name, lang.id] }, {}, class: "form-control"

.form-group
= f.label :liquid_layout_id, t('.layout_select')
= label_with_tooltip(f, :liquid_layout_id, t('pages.edit.layout_select'), t('tooltips.page_layout'))
.layout-settings
= render 'layout_select', field: :liquid_layout_id, f: f

Expand Down
8 changes: 5 additions & 3 deletions app/views/plugins/fundraisers/_fundraiser.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@
</div>
<div class="form__group">
<hr class="fundraiser-bar__step-connector fundraiser-bar__step-connector--static" />
<label class="checkbox-label">
<input class="fundraiser-bar__recurring" type="checkbox" name="recurring" /> {{ 'fundraiser.make_recurring' | t }}
</label>
</div>
</div>
<div class="form__group">
<label class="checkbox-label">
<input class="fundraiser-bar__recurring" type="checkbox" name="recurring" /> {{ 'fundraiser.make_recurring' | t }}
</label>
</div>
<button type="submit" class="button fundraiser-bar__submit-button">{{ 'form.submit' | t }}</button>
</form>
</div>
Expand Down
1 change: 1 addition & 0 deletions config/locales/sumofus.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ de:
card_declined: Der Zahlungsdienst hat Ihre Kreditkarte nicht akzeptiert. Bitte wählen Sie eine andere Zahlungsmethode.
unknown_error: Unbekannter Fehler. Unser Team wurde benachrichtigt. Bitte überprüfen Sie Ihre Eingaben oder wählen Sie eine andere Zahlungsmethode.
fine_print: "SumOfUs ist eine eingetragene Non-Profit-Organisation (501(c)4) mit Sitz in Washington DC, USA. Spenden an SumOfUs können nicht von der Steuer abgesetzt werden. Für mehr Informationen schreiben Sie uns bitte eine E-Mail an [email protected]."
confirmation: Donation received # FIXME - STILL IN ENGLISH!
fields:
cvv: Kartenprüfnummer
number: Kreditkartennummer
Expand Down
1 change: 1 addition & 0 deletions config/locales/sumofus.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ en:
card_declined: Your card was declined by the payment processor. Please try a different payment method.
unknown_error: Our technical team has been notified. Please double check your info or try a different payment method.
fine_print: "SumOfUs is a registered 501(c)4 non-profit incorporated in Washington, DC, United States. Contributions or gifts to SumOfUs are not tax deductible. For further information, please contact [email protected]."
confirmation: Donation received
fields:
cvv: CVV
number: Card number
Expand Down
1 change: 1 addition & 0 deletions config/locales/sumofus.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fr:
card_declined: Votre carte a été refusée par le service de paiement. Veuillez choisir une autre méthode de paiement.
unknown_error: Notre équipe technique a été notifiée de ce problème. Veuillez revérifier vos informations ou choisir une autre méthode de paiement.
fine_print: "SumOfUs est une ONG déclarée 501(c)4 à Washington DC, USA. Les contributions ou dons ne sont pas déductibles des impôts. Pour plus d’informations, veuillez nous contacter à cette adresse: [email protected]"
confirmation: Don reçu
fields:
cvv: CVV
number: Numéro de votre carte
Expand Down
63 changes: 1 addition & 62 deletions lib/tasks/champaign.rake
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
require './lib/liquid_markup_seeder'

namespace :champaign do
desc "Set plugins to active"
task activate_plugins: :environment do
puts "Starting update..."

Plugins.registered.each do |plugin|
plugin.all.each{|pl| pl.update({active: true}) }
end

puts "Update is done."
end

desc "Seed database with liquid markup for partials and templates"
task seed_liquid: :environment do
puts "Starting Liquid Markup Seeder..."
Expand All @@ -20,55 +9,5 @@ namespace :champaign do

puts "Seeding is done."
end

desc "ONE-OFF task for updating plugins to work with polymorphic forms"
task make_forms_poly: :environment do
[Plugins::Fundraiser, Plugins::Petition].each do |plugin_class|
plugin_class.all.each do |plugin|
form = Form.find(plugin.form_id)

if form
puts "Updating form #{form.id}"
form.update(formable: plugin)
end
end
end
end

desc "Seeds database with tags for campaigners"
task seed_campaigner_tags: :environment do
puts "Adding campaigner tags..."

campaigners=[
{ name: "JonL", actionkit_uri: "/rest/v1/tag/1015/" },
{ name: "KatherineT", actionkit_uri: "/rest/v1/tag/818/" },
{ name: "LedysS", actionkit_uri: "/rest/v1/tag/992/" },
{ name: "NicoleC", actionkit_uri: "/rest/v1/tag/1197/" },
{ name: "EmmaP", actionkit_uri: "/rest/v1/tag/1044/" },
{ name: "LizM", actionkit_uri: "/rest/v1/tag/1004/" },
{ name: "PaulF", actionkit_uri: "/rest/v1/tag/821/" },
{ name: "AngusW", actionkit_uri: "/rest/v1/tag/816/" },
{ name: "MartinC", actionkit_uri: "/rest/v1/tag/878/" },
{ name: "AnneI", actionkit_uri: "/rest/v1/tag/1018/" },
{ name: "WiebkeS", actionkit_uri: "/rest/v1/tag/1200/" },
{ name: "FatahS", actionkit_uri: "/rest/v1/tag/1102/" },
{ name: "NabilB", actionkit_uri: "/rest/v1/tag/1465/" },
{ name: "SondhyaG", actionkit_uri: "/rest/v1/tag/1651/" },
{ name: "HannaT", actionkit_uri: "/rest/v1/tag/817/" },
{ name: "RosaK", actionkit_uri: "/rest/v1/tag/1422/" },
{ name: "EoinD", actionkit_uri: "/rest/v1/tag/1112/" },
{ name: "HannahL", actionkit_uri: "/rest/v1/tag/982/" },
{ name: "StevenB", actionkit_uri: "/rest/v1/tag/911/" },
{ name: "MarkTP", actionkit_uri: "/rest/v1/tag/1019/" },
{ name: "BexS", actionkit_uri: "/rest/v1/tag/1388/" },
{ name: "MichaelS", actionkit_uri: "/rest/v1/tag/1160/" },
{ name: "DeborahL", actionkit_uri: "/rest/v1/tag/1661/" },
{ name: "KatieF", actionkit_uri: "/rest/v1/tag/1662/" }]

campaigners.each do |campaigner|
# Find the first tag named after the campaigner, or create a new one with the campaigner's name.
Tag.create_with(actionkit_uri: campaigner[:actionkit_uri]).find_or_create_by(name: campaigner[:name])
end
puts "Finished adding campaigner tags."
end
end

43 changes: 43 additions & 0 deletions spec/models/member_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,49 @@
end
end

describe 'validations' do
describe 'email' do
before do
create(:member, email: '[email protected]')
end

it 'must be unique' do
member = build(:member, email: '[email protected]')
expect(member).to be_invalid
expect(member.errors[:email]).to eq(["has already been taken"])
end

it 'can be nil' do
expect{
create(:member, email: nil)
create(:member, email: nil)
}.to_not raise_error
end
end
end

describe 'email' do
it 'is downcased on create' do
member = create(:member, email: '[email protected]')
expect(member.email).to eq('[email protected]')
end

it 'is downcased on save' do
member = create(:member, email: '[email protected]')
member.update(email: '[email protected]')
expect(member.email).to eq('[email protected]')
end

it 'is fine with nil' do
expect{
create(:member, email: nil)
}.to change{Member.count}.
from(0).to(1)

expect(Member.last.email).to be nil
end
end

describe 'liquid_data' do
it 'includes all attributes, plus name and welcome_name' do
m = create :member
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/api/actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

context 'existing member' do

let(:member) { create :member, actionkit_user_id: '1234', email: params[:email]}
let!(:member) { create :member, actionkit_user_id: '1234', email: params[:email]}

it 'does not overwrite existing actionkit_user_id' do
post "/api/pages/#{page.id}/actions", params
Expand Down
5 changes: 5 additions & 0 deletions spec/requests/api/braintree_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
email: "[email protected]",
postal: "11225",
address1: '25 Elm Drive',
akid: '1234.5678.9910',
source: 'fb',
country: "US"
}
Expand Down Expand Up @@ -124,6 +125,7 @@
country: "US",
postal: "11225",
address1: '25 Elm Drive',
akid: '1234.5678.9910',
source: 'fb',
first_name: 'Bernie',
last_name: 'Sanders'
Expand Down Expand Up @@ -334,6 +336,7 @@
email: "[email protected]",
country: "US",
postal: "11225",
akid: '1234.5678.9910',
source: 'fb',
address1: '25 Elm Drive',
first_name: 'Bernie',
Expand Down Expand Up @@ -640,6 +643,7 @@
country: "US",
postal: "11225",
address1: '25 Elm Drive',
akid: '1234.5678.9910',
source: 'fb',
first_name: 'Bernie',
last_name: 'Sanders'
Expand Down Expand Up @@ -888,6 +892,7 @@
address1: '25 Elm Drive',
first_name: 'Bernie',
last_name: 'Sanders',
akid: '1234.5678.9910',
source: 'fb'
},
action: {
Expand Down
3 changes: 3 additions & 0 deletions spec/requests/api/braintree_webhook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
email: "[email protected]",
postal: "11225",
address1: '25 Elm Drive',
akid: '1234.5678.9910',
source: 'fb',
country: "US"
}
Expand Down Expand Up @@ -108,6 +109,7 @@
postal: "11225",
address1: '25 Elm Drive',
source: 'fb',
akid: '1234.5678.9910',
first_name: 'Bernie',
last_name: 'Sanders'
},
Expand Down Expand Up @@ -160,6 +162,7 @@
postal: "11225",
address1: '25 Elm Drive',
source: 'fb',
akid: '1234.5678.9910',
first_name: 'Bernie',
last_name: 'Sanders'
},
Expand Down
9 changes: 7 additions & 2 deletions spec/services/action_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
let(:page) { create :page }
let(:member) { create :member }
let(:found_action) { Action.where(member: member, page: page).first }
let(:test_params) { {test: 'yes', foo: 'bar'}}

# Create a class which includes the ActionBuilder.
class MockActionBuilder
Expand Down Expand Up @@ -111,7 +110,7 @@ def initialize(params)

describe 'filters irrelevant' do

let(:porky_params) { params.merge(page_id: page.id, form_id: '3', blerg: false) }
let(:porky_params) { params.merge(page_id: page.id, form_id: '3', blerg: false, akid: '1234.514.lQVxcW') }

it 'keys as symbols' do
mab = MockActionBuilder.new(porky_params)
Expand All @@ -132,6 +131,12 @@ def initialize(params)
mab = MockActionBuilder.new(ActionController::Parameters.new(porky_params))
expect(mab.filtered_params).to eq params
end

it 'but passes them through to form_data' do
mab = MockActionBuilder.new(porky_params)
expect{ mab.build_action }.to change{ Action.count }.by 1
expect(Action.last.form_data).to match a_hash_including(params.stringify_keys)
end
end
end
end
Expand Down

0 comments on commit a91b007

Please sign in to comment.