Drop caching

This commit is contained in:
Hakan Ensari 2017-01-10 12:21:19 +00:00
parent 11f3ddb0e4
commit e5cb17d0b9
8 changed files with 2 additions and 40 deletions

View File

@ -2,6 +2,4 @@ before_script:
- psql -c 'create database fixer_test;' -U postgres
rvm:
- 2.4.0
services:
- memcached
sudo: false

View File

@ -6,4 +6,4 @@ ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install --without development test
ADD . /app
CMD ./wait-for-it.sh db:5432 -s -- wait-for-it.sh memcache:11211 -s -- unicorn -c /app/config/unicorn.rb
CMD ./wait-for-it.sh db:5432 -s -- unicorn -c /app/config/unicorn.rb

View File

@ -3,12 +3,10 @@ source 'http://rubygems.org'
ruby '2.4.0'
gem 'dalli'
gem 'fixer'
gem 'kgio'
gem 'newrelic_rpm'
gem 'oj'
gem 'rack-cache'
gem 'rack-cors'
gem 'rake'
gem 'sequel_pg'

View File

@ -3,7 +3,6 @@ GEM
specs:
ast (2.3.0)
coderay (1.1.1)
dalli (2.7.6)
fixer (0.7.0)
kgio (2.11.0)
method_source (0.8.2)
@ -21,8 +20,6 @@ GEM
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.5)
rack-cache (1.6.1)
rack (>= 0.4)
rack-cors (0.4.0)
rack-protection (1.5.3)
rack
@ -59,7 +56,6 @@ PLATFORMS
ruby
DEPENDENCIES
dalli
fixer
kgio
minitest
@ -67,7 +63,6 @@ DEPENDENCIES
newrelic_rpm
oj
pry
rack-cache
rack-cors
rack-test
rake

View File

@ -2,8 +2,6 @@ version: '2'
services:
db:
image: postgres
memcache:
image: memcached
web:
build: .
volumes:
@ -13,7 +11,5 @@ services:
environment:
RACK_ENV: production
DATABASE_URL: postgres://postgres@db/postgres
MEMCACHE_SERVERS: memcache
links:
- db
- memcache

View File

@ -1,16 +1,9 @@
# frozen_string_literal: true
require 'dalli'
require 'oj'
require 'sinatra'
require 'rack/cache'
require 'rack/cors'
require 'quote'
use Rack::Cache,
verbose: true,
metastore: "memcached://#{ENV['MEMCACHE_SERVERS']}/meta",
entitystore: "memcached://#{ENV['MEMCACHE_SERVERS']}/body"
use Rack::Cors do
allow do
origins '*'
@ -34,14 +27,11 @@ helpers do
def quote_attributes
@quote_attributes ||= quote.attributes.tap do |data|
symbols = params.values_at('symbols', 'to').compact.first
data[:rates].keep_if { |k, _| symbols.include?(k) } if symbols
end
end
def symbols
@symbols ||= params.values_at('symbols', 'to').compact.first
end
def jsonp(data)
json = encode_json(data)
callback = params.delete('callback')

View File

@ -10,10 +10,6 @@ describe 'the API' do
let(:json) { Oj.load(last_response.body) }
let(:headers) { last_response.headers }
before do
Dalli::Client.new.flush
end
it 'describes itself' do
get '/'
last_response.must_be :ok?
@ -101,11 +97,4 @@ describe 'the API' do
get '/latest?from=GBP&to=USD&amount=100'
json['rates']['USD'].must_be :>, 100
end
it 'sets Content-Type header to JSON when caching' do
2.times do
get '/latest'
last_response.headers['Content-Type'].must_equal 'application/json'
end
end
end

View File

@ -9,10 +9,6 @@ describe 'the API' do
let(:app) { Sinatra::Application }
let(:json) { Oj.load(last_response.body) }
before do
Dalli::Client.new.flush
end
it 'handles unfound pages' do
get '/foo'
last_response.status.must_equal 404