Skip to content

Commit

Permalink
Fixed canceled spelling thing, again
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Fordham committed Apr 25, 2011
1 parent 6c2e208 commit ef15f86
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 46 deletions.
Expand Up @@ -28,7 +28,7 @@ def cancel
@subscription = Subscription.find(params[:id])
@subscription.cancel
redirect_to admin_subscription_path(@subscription)
flash[:notice] = "Subscription was cancelled."
flash[:notice] = "Subscription was canceled."
end

end
2 changes: 1 addition & 1 deletion app/controllers/saasaparilla/subscription_controller.rb
Expand Up @@ -49,7 +49,7 @@ def reactivate

def destroy
if @subscription.cancel
flash[:notice] = "Your subscription has been cancelled."
flash[:notice] = "Your subscription has been canceled."
redirect_to subscription_path

end
Expand Down
6 changes: 3 additions & 3 deletions app/mailers/saasaparilla/notifier.rb
Expand Up @@ -27,12 +27,12 @@ def billing_failed(subscription)
def pending_cancellation_notice(subscription)
@subscription = subscription
@url = edit_subscription_credit_card_url
mail(:to => subscription.contact_info.email, :subject => "Your subscription will be cancelled soon")
mail(:to => subscription.contact_info.email, :subject => "Your subscription will be canceled soon")
end

def subscription_cancelled(subscription)
def subscription_canceled(subscription)
@subscription = subscription
mail(:to => subscription.contact_info.email, :subject => "Your subscription has been cancelled")
mail(:to => subscription.contact_info.email, :subject => "Your subscription has been canceled")
end

end
6 changes: 3 additions & 3 deletions app/models/subscription.rb
Expand Up @@ -146,7 +146,7 @@ def invoice!

def cancel
set_canceled
send_subscription_cancelled_email
send_subscription_canceled_email
end

def reactivate!
Expand Down Expand Up @@ -356,8 +356,8 @@ def send_pending_cancellation_notice_email
Saasaparilla::Notifier.pending_cancellation_notice(self).deliver
end

def send_subscription_cancelled_email
Saasaparilla::Notifier.subscription_cancelled(self).deliver
def send_subscription_canceled_email
Saasaparilla::Notifier.subscription_canceled(self).deliver
end

end
2 changes: 1 addition & 1 deletion app/views/saasaparilla/admin/subscriptions/show.html.haml
Expand Up @@ -40,7 +40,7 @@
.info
%h2 Actions
%p
= link_to "Cancel Subscription", cancel_admin_subscription_path(@subscription), :confirm => "Are you sure you want to cancel this subscription?" unless @subscription.status == "cancelled"
= link_to "Cancel Subscription", cancel_admin_subscription_path(@subscription), :confirm => "Are you sure you want to cancel this subscription?" unless @subscription.status == "canceled"
%br
- if @subscription.no_charge
= link_to "Revoke complimentary subscription", toggle_no_charge_admin_subscription_path(@subscription), :confirm => "Are you sure you want to comp this subscription?"
Expand Down
@@ -1,6 +1,6 @@
%h2 Your account will be cancelled soon
%h2 Your account will be canceled soon

%p
= "Our attempt to charge your credit card #{number_to_currency(@amount)} for your #{@subscription.plan.billing_period} subscription to the #{@subscription.plan.name} plan has failed multiple times. Please visit #{@url} to fix this problem."
If this problem is not fixed soon, your account will be cancelled and deleted.
If this problem is not fixed soon, your account will be canceled and deleted.
If you need any assistance, please contact the administrator.
@@ -0,0 +1,4 @@
%h2 Your subscription has been canceled

%p
Your subscription has been canceled. If you need any further assistance, please contact the administrator.

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/saasaparilla/subscription/show.html.haml
Expand Up @@ -2,7 +2,7 @@
%h1 Subscription


- if @subscription.status == "cancelled"
- if @subscription.status == "canceled"
.info
%p
You do not have an active paid subscription.
Expand Down
10 changes: 5 additions & 5 deletions spec/dummy/public/javascripts/jquery.js
Expand Up @@ -930,14 +930,14 @@ jQuery.extend({
fired,
// to avoid firing when already doing so
firing,
// flag to know if the deferred has been cancelled
cancelled,
// flag to know if the deferred has been canceled
canceled,
// the deferred itself
deferred = {

// done( f1, f2, ...)
done: function() {
if ( !cancelled ) {
if ( !canceled ) {
var args = arguments,
i,
length,
Expand Down Expand Up @@ -966,7 +966,7 @@ jQuery.extend({

// resolve with given context and args
resolveWith: function( context, args ) {
if ( !cancelled && !fired && !firing ) {
if ( !canceled && !fired && !firing ) {
// make sure args are available (#8421)
args = args || [];
firing = 1;
Expand Down Expand Up @@ -996,7 +996,7 @@ jQuery.extend({

// Cancel
cancel: function() {
cancelled = 1;
canceled = 1;
callbacks = [];
return this;
}
Expand Down
6 changes: 3 additions & 3 deletions spec/mailers/notifier_spec.rb
Expand Up @@ -143,23 +143,23 @@
end


describe 'subscription cancelled email' do
describe 'subscription canceled email' do

before(:all) do
plan = Factory.build(:plan, :name => "Gold", :price => 20.0)
contact_info = Factory.build(:contact_info)

credit_card = Factory.build(:credit_card)
@subscription = Factory.build(:subscription, :contact_info => contact_info, :plan => plan, :credit_card => credit_card)
@email = Saasaparilla::Notifier.subscription_cancelled(@subscription)
@email = Saasaparilla::Notifier.subscription_canceled(@subscription)
end

it "should deliver to the subscription passed in" do
@email.should deliver_to(@subscription.contact_info.email)
end

it "should contain the plan in the mail body" do
@email.should have_body_text(/Your subscription has been cancelled/)
@email.should have_body_text(/Your subscription has been canceled/)
end

end
Expand Down
28 changes: 8 additions & 20 deletions spec/models/subscription_spec.rb
Expand Up @@ -195,7 +195,7 @@
@subscription.billing_activities.count.should == 1
end

it 'should reactivate cancelled accounts' do
it 'should reactivate canceled accounts' do
@subscription.update_attributes(:status => "canceled")
@subscription.reactivate!
@subscription.status.should == "active"
Expand All @@ -207,7 +207,7 @@

describe 'billing' do
before(:each) do
@plan = Factory(:plan, :name => "Gold", :price => 20.0)
plan = Factory(:plan, :name => "Gold", :price => 20.0)
plan2 = Factory(:plan, :name => "Gold", :price => 20.0, :billing_period => "annually")
contact_info1 = Factory.build(:contact_info)
contact_info2 = Factory.build(:contact_info)
Expand All @@ -217,9 +217,9 @@
credit_card2 = Factory.build(:credit_card)
credit_card3 = Factory.build(:credit_card)
credit_card4 = Factory.build(:credit_card)
@subscription1 = Factory(:subscription, :contact_info => contact_info1, :plan => @plan, :credit_card => credit_card1)
@subscription2 = Factory(:subscription, :contact_info => contact_info2, :plan => @plan, :credit_card => credit_card2)
@subscription3 = Factory(:subscription, :contact_info => contact_info3, :plan => @plan, :credit_card => credit_card3)
@subscription1 = Factory(:subscription, :contact_info => contact_info1, :plan => plan, :credit_card => credit_card1)
@subscription2 = Factory(:subscription, :contact_info => contact_info2, :plan => plan, :credit_card => credit_card2)
@subscription3 = Factory(:subscription, :contact_info => contact_info3, :plan => plan, :credit_card => credit_card3)
@subscription4 = Factory(:subscription, :contact_info => contact_info4, :plan => plan2, :credit_card => credit_card4)
@subscription1.update_attributes(:balance => 12, :billing_date => Date.today)
@subscription2.update_attributes(:balance => 12, :billing_date => Date.today)
Expand Down Expand Up @@ -325,7 +325,7 @@
@subscription1.reload.canceled?.should == true
end

it 'should send subscription_cancelled email if failed over grace period' do
it 'should send subscription_canceled email if failed over grace period' do
ActionMailer::Base.deliveries = [];
@subscription1.update_attributes(:billing_date => Date.today - 11.days, :status => "overdue")
@subscription2.update_attributes(:status => 'canceled')
Expand All @@ -334,7 +334,7 @@
GATEWAYCIM.success = false
Subscription.find_and_bill_recurring_subscriptions
GATEWAYCIM.success = true
ActionMailer::Base.deliveries.first.subject.should =~ /Your subscription has been cancelled/
ActionMailer::Base.deliveries.first.subject.should =~ /Your subscription has been canceled/
end

it 'should send pending_cancellation_notice email if failed and 1 day before over grace period' do
Expand All @@ -345,7 +345,7 @@
@subscription3.update_attributes(:status => 'canceled')
@subscription4.update_attributes(:status => 'canceled')
Subscription.find_and_bill_recurring_subscriptions
ActionMailer::Base.deliveries.first.subject.should =~ /Your subscription will be cancelled soon/
ActionMailer::Base.deliveries.first.subject.should =~ /Your subscription will be canceled soon/
GATEWAYCIM.success = true
end

Expand Down Expand Up @@ -401,18 +401,6 @@
@subscription1.billing_activities.last.invoice.invoice_line_items.first.to.should == @subscription1.billing_date
end

it 'should downgrade plan at the end of the billing period on downgrade' do
@plan2 = Factory(:plan, :name => "silver", :price => "10.00")
@subscription1.downgrade_to_plan = @plan2
@subscription1.save
@subscription1.plan.should == @plan
@subscription1.downgrade_to_plan.should == @plan2
Subscription.find_and_bill_recurring_subscriptions
@subscription1.reload
@subscription1.plan.should == @plan2
@subscription1.downgrade_to_plan.should == nil
end


end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/subscriptions_spec.rb
Expand Up @@ -70,10 +70,10 @@
end


it 'should set subscription status to cancelled' do
it 'should set subscription status to canceled' do
visit subscription_path
click_on "Cancel Subscription"
page.should have_content("Your subscription has been cancelled.")
page.should have_content("Your subscription has been canceled.")
end
end

Expand Down

0 comments on commit ef15f86

Please sign in to comment.