Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

CLC-1535 Hide Bearfacts behind feature flag #869

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 25, 2013
  1. @ctweney
This page is out of date. Refresh to see the latest.
View
1  config/settings.yml
@@ -139,3 +139,4 @@ developer_auth:
# feature toggles. If a feature's key is false OR nil, it's disabled.
features:
act_as: false
+ bearfacts: false
View
1  config/settings/test.yml
@@ -18,3 +18,4 @@ oauth2:
features:
act_as: true
+ bearfacts: true
View
2  config/settings/testext.yml
@@ -15,3 +15,5 @@ campusdb:
features:
act_as: true
+ bearfacts: true
+
View
25 lib/proxies/bearfacts_proxy.rb
@@ -16,13 +16,20 @@ def lookup_student_id
end
def request(path, vcr_cassette, params = {})
+ unless Settings.features.bearfacts
+ return {
+ :body => "",
+ :status_code => 200
+ }
+ end
+
self.class.fetch_from_cache(@uid) do
student_id = lookup_student_id
if student_id.nil?
Rails.logger.warn "#{self.class.name}: Lookup of student_id for uid #@uid failed, cannot call Bearfacts API path #{path}"
{
- :body => "Lookup of student_id for uid #@uid failed, cannot call Bearfacts API",
- :status_code => 400
+ :body => "Lookup of student_id for uid #@uid failed, cannot call Bearfacts API",
+ :status_code => 400
}
else
url = "#{Settings.bearfacts_proxy.base_url}#{path}"
@@ -30,9 +37,9 @@ def request(path, vcr_cassette, params = {})
begin
response = FakeableProxy.wrap_request(APP_ID + "_" + vcr_cassette, @fake, {:match_requests_on => [:method, :path]}) {
Faraday::Connection.new(
- :url => url,
- :params => params.merge({:token => Settings.bearfacts_proxy.token}),
- :ssl => {:verify => false}
+ :url => url,
+ :params => params.merge({:token => Settings.bearfacts_proxy.token}),
+ :ssl => {:verify => false}
).get
}
if response.status >= 400
@@ -42,14 +49,14 @@ def request(path, vcr_cassette, params = {})
Rails.logger.debug "#{self.class.name}: Remote server status #{response.status}, Body = #{response.body}"
{
- :body => response.body,
- :status_code => response.status
+ :body => response.body,
+ :status_code => response.status
}
rescue Faraday::Error::ConnectionFailed, Faraday::Error::TimeoutError => e
Rails.logger.warn "#{self.class.name}: Connection failed: #{e.class} #{e.message}"
{
- :body => "Remote server unreachable",
- :status_code => 503
+ :body => "Remote server unreachable",
+ :status_code => 503
}
end
end
Something went wrong with that request. Please try again.