@@ -32,8 +32,8 @@ class Service < ActiveRecord::Base |
||
| 32 | 32 |
def refresh_token! |
| 33 | 33 |
response = HTTParty.post(endpoint, query: {
|
| 34 | 34 |
type: 'refresh', |
| 35 |
- client_id: ENV["#{self.provider.upcase}_OAUTH_KEY"],
|
|
| 36 |
- client_secret: ENV["#{self.provider.upcase}_OAUTH_SECRET"],
|
|
| 35 |
+ client_id: ENV["#{provider_to_env}_OAUTH_KEY"],
|
|
| 36 |
+ client_secret: ENV["#{provider_to_env}_OAUTH_SECRET"],
|
|
| 37 | 37 |
refresh_token: self.refresh_token |
| 38 | 38 |
}) |
| 39 | 39 |
data = JSON.parse(response.body) |
@@ -67,4 +67,9 @@ class Service < ActiveRecord::Base |
||
| 67 | 67 |
client_options = "OmniAuth::Strategies::#{OmniAuth::Utils.camelize(self.provider)}".constantize.default_options['client_options']
|
| 68 | 68 |
URI.join(client_options['site'], client_options['token_url']) |
| 69 | 69 |
end |
| 70 |
+ |
|
| 71 |
+ @@provider_to_env_map = {'37signals' => 'THIRTY_SEVEN_SIGNALS'}
|
|
| 72 |
+ def provider_to_env |
|
| 73 |
+ @@provider_to_env_map[self.provider].presence || self.provider.upcase |
|
| 74 |
+ end |
|
| 70 | 75 |
end |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 |
# |
| 12 | 12 |
# It's strongly recommended that you check this file into your version control system. |
| 13 | 13 |
|
| 14 |
-ActiveRecord::Schema.define(version: 20140723110551) do |
|
| 14 |
+ActiveRecord::Schema.define(version: 20140730005210) do |
|
| 15 | 15 |
|
| 16 | 16 |
# These are extensions that must be enabled in order to support this database |
| 17 | 17 |
enable_extension "plpgsql" |
@@ -10,7 +10,7 @@ describe ServicesController do |
||
| 10 | 10 |
describe "GET index" do |
| 11 | 11 |
it "only returns sevices of the current user" do |
| 12 | 12 |
get :index |
| 13 |
- assigns(:services).all? {|i| i.user.should == users(:bob) }.should be_true
|
|
| 13 |
+ assigns(:services).all? {|i| i.user.should == users(:bob) }.should == true
|
|
| 14 | 14 |
end |
| 15 | 15 |
end |
| 16 | 16 |
|
@@ -20,7 +20,7 @@ describe Service do |
||
| 20 | 20 |
service.destroy |
| 21 | 21 |
agent.reload |
| 22 | 22 |
agent.service_id.should be_nil |
| 23 |
- agent.disabled.should be_true |
|
| 23 |
+ agent.disabled.should be true |
|
| 24 | 24 |
end |
| 25 | 25 |
|
| 26 | 26 |
describe "preparing for a request" do |
@@ -10,7 +10,7 @@ end |
||
| 10 | 10 |
|
| 11 | 11 |
# Required ENV variables that are normally set in .env are setup here for the test environment. |
| 12 | 12 |
require 'dotenv' |
| 13 |
-Dotenv.load File.join(File.dirname(__FILE__), "env.test") |
|
| 13 |
+Dotenv.overload File.join(File.dirname(__FILE__), "env.test") |
|
| 14 | 14 |
|
| 15 | 15 |
require File.expand_path("../../config/environment", __FILE__)
|
| 16 | 16 |
require 'rspec/rails' |