Skip to content

Commit

Permalink
Merge pull request #625 from theodi/bulk-import-coupon-codes
Browse files Browse the repository at this point in the history
Bulk import coupon codes
  • Loading branch information
Floppy committed Dec 10, 2015
2 parents 090a104 + fe8efef commit 4ce3576
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/controllers/uploads_controller.rb
Expand Up @@ -35,6 +35,7 @@ def sample
"course_start_year" => "2013",
"course_end_month" => "06",
"course_end_year" => "2016",
"coupon_code" => "SUPERFREE"
}
csv << sample_data.keys
csv << sample_data.values
Expand Down Expand Up @@ -73,6 +74,7 @@ def create_student_member_from_row(row)
university_course_start_date_month: row["course_start_month"],
university_course_end_date_year: row["course_end_year"],
university_course_end_date_month: row["course_end_month"],
coupon: row["coupon_code"],
)
end

Expand Down
1 change: 1 addition & 0 deletions features/bulk_student_upload.feature
Expand Up @@ -3,6 +3,7 @@ Feature: Bulk upload of student members
Background:
Given I am logged in as an administrator
And I visit the student bulk upload page
And the student coupon code SUPERFREE is in Chargify

Scenario: Download a template CSV file
When I click "Download template CSV"
Expand Down
3 changes: 3 additions & 0 deletions features/step_definitions/bulk_upload_steps.rb
Expand Up @@ -30,6 +30,7 @@
course_start_year
course_end_month
course_end_year
coupon_code
}
end

Expand All @@ -53,6 +54,7 @@
expect(row["course_start_year"]).to eql "2013"
expect(row["course_end_month"]).to eql "06"
expect(row["course_end_year"]).to eql "2016"
expect(row["coupon_code"]).to eql "SUPERFREE"
end

When(/^that file contains a set of student details$/) do
Expand All @@ -78,6 +80,7 @@
@share_with_third_parties = false
@payment_method = "credit_card"
@product_name = "student"
@coupon = double(code: "SUPERFREE")
end

When(/^I select the file "(.*?)" for upload$/) do |arg1|
Expand Down
8 changes: 8 additions & 0 deletions features/step_definitions/signup_steps.rb
Expand Up @@ -14,6 +14,14 @@
Member.register_chargify_coupon_code(@coupon)
end

Given /^the student coupon code SUPERFREE is in Chargify$/ do
@chargify_product_url = "http://test.host/product/individual-supporter-student"
@chargify_product_price = 800
@coupon = double(:code => "SUPERFREE", :percentage => 100)
Member.register_chargify_product_price("individual-supporter-student", @chargify_product_price*100)
Member.register_chargify_coupon_code(@coupon)
end

Given /^there is already an organization with the name I want to use$/ do
FactoryGirl.create :member, :organization_name => 'FooBar Inc'
end
Expand Down
4 changes: 2 additions & 2 deletions fixtures/upload/students.csv
@@ -1,2 +1,2 @@
name,email,dob_day,dob_month,dob_year,address_street,address_locality,address_town,address_country,address_postcode,university_name,qualification,course_name,course_start_month,course_start_year,course_end_month,course_end_year
"Bob Fish","bob@example.edu","01","02","1990","29 Acacia Road","","London","GB","SW1A 1AA","University of Life","BSc - Bachelor of Science","Quantum Morphogenetics","09","2013","06","2016"
name,email,dob_day,dob_month,dob_year,address_street,address_locality,address_town,address_country,address_postcode,university_name,qualification,course_name,course_start_month,course_start_year,course_end_month,course_end_year,coupon_code
"Bob Fish","bob@example.edu","01","02","1990","29 Acacia Road","","London","GB","SW1A 1AA","University of Life","BSc - Bachelor of Science","Quantum Morphogenetics","09","2013","06","2016","SUPERFREE"
3 changes: 2 additions & 1 deletion lib/noninteractive_add_to_chargify.rb
Expand Up @@ -11,7 +11,8 @@ def self.perform(member_id)
subscription = Chargify::Subscription.create(
:customer_attributes => ch.customer_attributes,
:product_handle => ch.product_handle,
:payment_profile => ch.payment_profile_attributes
:payment_profile => ch.payment_profile_attributes,
:coupon_code => member.coupon
)
member.update_chargify_values!(
customer_id: subscription.customer.id,
Expand Down

0 comments on commit 4ce3576

Please sign in to comment.