Permalink
Browse files

Cache results from heroku and travis ci api.

  • Loading branch information...
1 parent 3793368 commit 4684fa7b350e18d692cf8ba9110323a21edeec18 @skorfmann skorfmann committed Oct 21, 2012
Showing with 7 additions and 3 deletions.
  1. +2 −3 app/models/heroku_release.rb
  2. +5 −0 spec/models/heroku_release_spec.rb
@@ -6,14 +6,13 @@ class HerokuRelease < OpenStruct
class << self
def get_releases
- @travis_ci_builds = nil
- heroku.get_releases(HEROKU_APP_NAME).body.map do |release|
+ @@heroku_releases ||= heroku.get_releases(HEROKU_APP_NAME).body.map do |release|
new(get_attributes(release))
end
end
def get_travis_ci_builds
- @travis_ci_builds ||= HTTParty.get(TRAVIS_CI_BUILDS_API_URL)
+ @@travis_ci_builds ||= HTTParty.get(TRAVIS_CI_BUILDS_API_URL)
end
private
@@ -12,6 +12,11 @@
JSON.parse(json)
end
+ before do
+ HerokuRelease.class_variable_set('@@heroku_releases', nil)
+ HerokuRelease.class_variable_set('@@travis_ci_builds', nil)
+ end
+
context 'get_releases' do
before do
response = Object.new

0 comments on commit 4684fa7

Please sign in to comment.