· 9 years ago · Sep 21, 2016, 01:04 PM
1dima@dima-Aspire-ES1-512:~/rails_project/accountdock-rails-master$ git diff
2diff --git a/app/controllers/slack_controller.rb b/app/controllers/slack_controller.rb
3index 2815fe8..b93d3e1 100644
4--- a/app/controllers/slack_controller.rb
5+++ b/app/controllers/slack_controller.rb
6@@ -18,7 +18,7 @@ class SlackController < ApplicationController
7 slack_bot_id: response['bot']['bot_user_id'],
8 slack_bot_access_token: response['bot']['bot_access_token']
9 )
10- flash[:notice] = "Slack was successfully setup"
11+ flash[:notice] = 'Slack was successfully setup'
12 redirect_to team_customization_path
13 end
14 end
15diff --git a/app/controllers/stripe_controller.rb b/app/controllers/stripe_controller.rb
16index c062cf0..ead37bf 100644
17--- a/app/controllers/stripe_controller.rb
18+++ b/app/controllers/stripe_controller.rb
19@@ -41,15 +41,16 @@ class StripeController < ApplicationController
20 end
21
22 # Add connections
23- account.add_connection({
24- scope: token_params[:scope],
25- client_id: token_params[:stripe_client_id],
26- refresh_token: token_params[:refresh_token],
27- secret_key: token_params[:access_token],
28- vendor_customer_id: token_params[:stripe_user_id],
29- publishable_key: token_params[:stripe_publishable_key],
30- type: 'StripeConnection'
31- })
32+ account.add_connection(
33+ StripeConnection.new(
34+ scope: token_params[:scope],
35+ client_id: token_params[:stripe_client_id],
36+ refresh_token: token_params[:refresh_token],
37+ secret_key: token_params[:access_token],
38+ vendor_customer_id: token_params[:stripe_user_id],
39+ publishable_key: token_params[:stripe_publishable_key]
40+ )
41+ )
42
43 account.update(stripe_account_raw: stripe_account.to_json)
44
45@@ -57,5 +58,4 @@ class StripeController < ApplicationController
46
47 redirect_to team_switch_path(public_key: account.public_key, mode: params[:mode], path: 'dashboard')
48 end
49-
50 end
51diff --git a/app/controllers/team/home_controller.rb b/app/controllers/team/home_controller.rb
52index d7e064d..b358eeb 100644
53--- a/app/controllers/team/home_controller.rb
54+++ b/app/controllers/team/home_controller.rb
55@@ -13,13 +13,13 @@ class Team::HomeController < Team::BaseController
56
57 def customization
58 @setting = current_account.setting
59- @expiring_cc_day_ranges = Setting::expiring_cc_day_ranges
60+ @expiring_cc_day_ranges = Setting.expiring_cc_day_ranges
61 end
62
63 def view_payment_failed_email
64 @customer = current_account.customers.new(email: current_user.email,
65 stripe_customer_id: 'cus_1234')
66- @customer.cards.new(name: "Test Customer")
67+ @customer.cards.new(name: 'Test Customer')
68 render text: process_template(@customer, current_account.setting.first_failed_payment_body)
69 end
70 end
71diff --git a/app/models/account.rb b/app/models/account.rb
72index d4857c5..33f8e20 100644
73--- a/app/models/account.rb
74+++ b/app/models/account.rb
75@@ -131,13 +131,14 @@ class Account < ActiveRecord::Base
76
77 # Add a Stripe connection
78 def add_connection(params)
79- if self.connections.find_by(type: params[BraintreeConnection]).blank?
80+ binding.pry
81+ if self.connections.find_by(type: params[:type]).blank?
82 self.connections.create(params)
83 # Queue an initial sync of Stripe data to our local DB so Customers, etc show in
84 # our UI and can be used for queries on expiry, etc.
85 AccountSyncJob.perform_later(self) unless self.connections.first.try(:synced)
86 else
87- self.connections.first.update_attributes!(params)
88+ self.connections.find_by(type: params[:type]).update_attributes!(params)
89 end
90 end