From 834f3c4388626aea283a62de75f6aa0508fc7538 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 3 Nov 2016 18:53:37 +0100 Subject: [PATCH] Add tests for recently added API end points --- config/environments/development.rb | 8 +++++- .../api/v1/accounts_controller_spec.rb | 14 ++++++++++ .../api/v1/statuses_controller_spec.rb | 26 +++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 3a2ab2a0ea..829edcf041 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,7 +16,13 @@ Rails.application.configure do if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true - config.cache_store = :memory_store + config.cache_store = :redis_store, { + host: ENV['REDIS_HOST'] || 'localhost', + port: ENV['REDIS_PORT'] || 6379, + db: 0, + namespace: 'cache' + } + config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=172800' } diff --git a/spec/controllers/api/v1/accounts_controller_spec.rb b/spec/controllers/api/v1/accounts_controller_spec.rb index e4532305b6..98eea28ce6 100644 --- a/spec/controllers/api/v1/accounts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts_controller_spec.rb @@ -46,6 +46,20 @@ RSpec.describe Api::V1::AccountsController, type: :controller do end end + describe 'GET #suggestions' do + it 'returns http success' do + get :suggestions + expect(response).to have_http_status(:success) + end + end + + describe 'GET #common_followers' do + it 'returns http success' do + get :common_followers, params: { id: user.account.id } + expect(response).to have_http_status(:success) + end + end + describe 'POST #follow' do let(:other_account) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account } diff --git a/spec/controllers/api/v1/statuses_controller_spec.rb b/spec/controllers/api/v1/statuses_controller_spec.rb index 66060c57e9..cf0b3649f8 100644 --- a/spec/controllers/api/v1/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/statuses_controller_spec.rb @@ -33,6 +33,32 @@ RSpec.describe Api::V1::StatusesController, type: :controller do end end + describe 'GET #reblogged_by' do + let(:status) { Fabricate(:status, account: user.account) } + + before do + post :reblog, params: { id: status.id } + end + + it 'returns http success' do + get :reblogged_by, params: { id: status.id } + expect(response).to have_http_status(:success) + end + end + + describe 'GET #favourited_by' do + let(:status) { Fabricate(:status, account: user.account) } + + before do + post :favourite, params: { id: status.id } + end + + it 'returns http success' do + get :favourited_by, params: { id: status.id } + expect(response).to have_http_status(:success) + end + end + describe 'GET #home' do it 'returns http success' do get :home