From a3dcbfddd6869f6bdc28f348c07ba70a764b94cc Mon Sep 17 00:00:00 2001 From: ysksn Date: Mon, 17 Dec 2018 14:03:51 +0900 Subject: Add specs for Accounts::PinsController (#9542) --- .../api/v1/accounts/pins_controller_spec.rb | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 spec/controllers/api/v1/accounts/pins_controller_spec.rb (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/accounts/pins_controller_spec.rb b/spec/controllers/api/v1/accounts/pins_controller_spec.rb new file mode 100644 index 000000000..c71935df2 --- /dev/null +++ b/spec/controllers/api/v1/accounts/pins_controller_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Api::V1::Accounts::PinsController, type: :controller do + let(:john) { Fabricate(:user, account: Fabricate(:account, username: 'john')) } + let(:kevin) { Fabricate(:user, account: Fabricate(:account, username: 'kevin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: john.id, scopes: 'write:accounts') } + + before do + kevin.account.followers << john.account + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'POST #create' do + subject { post :create, params: { account_id: kevin.account.id } } + + it 'returns 200' do + expect(response).to have_http_status(200) + end + + it 'creates account_pin' do + expect do + subject + end.to change { AccountPin.where(account: john.account, target_account: kevin.account).count }.by(1) + end + end + + describe 'DELETE #destroy' do + subject { delete :destroy, params: { account_id: kevin.account.id } } + + before do + Fabricate(:account_pin, account: john.account, target_account: kevin.account) + end + + it 'returns 200' do + expect(response).to have_http_status(200) + end + + it 'destroys account_pin' do + expect do + subject + end.to change { AccountPin.where(account: john.account, target_account: kevin.account).count }.by(-1) + end + end +end -- cgit From 3fa9615cb3050a34824f6450ae9de76d6e0e8f6c Mon Sep 17 00:00:00 2001 From: ysksn Date: Mon, 17 Dec 2018 19:32:24 +0900 Subject: Add spec for Api::V1::Instances::ActivityController (#9545) --- .../api/v1/instances/activity_controller_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/controllers/api/v1/instances/activity_controller_spec.rb (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/instances/activity_controller_spec.rb b/spec/controllers/api/v1/instances/activity_controller_spec.rb new file mode 100644 index 000000000..159792ee0 --- /dev/null +++ b/spec/controllers/api/v1/instances/activity_controller_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Api::V1::Instances::ActivityController, type: :controller do + describe 'GET #show' do + it 'returns 200' do + get :show + expect(response).to have_http_status(200) + end + + context '!Setting.activity_api_enabled' do + it 'returns 404' do + Setting.activity_api_enabled = false + + get :show + expect(response).to have_http_status(404) + end + end + end +end -- cgit From 2d871feb10e42becb9248e44e108ebcc93b671fe Mon Sep 17 00:00:00 2001 From: ysksn Date: Mon, 17 Dec 2018 19:32:44 +0900 Subject: Add spec for Api::V1::EndorsementsController (#9543) --- spec/controllers/api/v1/endorsements_controller_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 spec/controllers/api/v1/endorsements_controller_spec.rb (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/endorsements_controller_spec.rb b/spec/controllers/api/v1/endorsements_controller_spec.rb new file mode 100644 index 000000000..ad5ff400f --- /dev/null +++ b/spec/controllers/api/v1/endorsements_controller_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Api::V1::EndorsementsController, type: :controller do + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') } + + describe 'GET #index' do + it 'returns 200' do + allow(controller).to receive(:doorkeeper_token) { token } + get :index + + expect(response).to have_http_status(200) + end + end +end -- cgit From 351938520d5e5e8792772fd5f8ad30ba3e11639c Mon Sep 17 00:00:00 2001 From: ysksn Date: Mon, 17 Dec 2018 19:35:55 +0900 Subject: Add specs for Api::V1::Instances::PeersController (#9546) --- .../api/v1/instances/peers_controller_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/controllers/api/v1/instances/peers_controller_spec.rb (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/instances/peers_controller_spec.rb b/spec/controllers/api/v1/instances/peers_controller_spec.rb new file mode 100644 index 000000000..12a214a83 --- /dev/null +++ b/spec/controllers/api/v1/instances/peers_controller_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Api::V1::Instances::PeersController, type: :controller do + describe 'GET #index' do + it 'returns 200' do + get :index + expect(response).to have_http_status(200) + end + + context '!Setting.peers_api_enabled' do + it 'returns 404' do + Setting.peers_api_enabled = false + + get :index + expect(response).to have_http_status(404) + end + end + end +end -- cgit From 0c8071523592fc4ce73aa5c39822ca5d7f5f71d7 Mon Sep 17 00:00:00 2001 From: ysksn Date: Mon, 17 Dec 2018 19:36:20 +0900 Subject: Add spec for Api::V1::Timelines::DirectController (#9547) --- .../api/v1/timelines/direct_controller_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 spec/controllers/api/v1/timelines/direct_controller_spec.rb (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/timelines/direct_controller_spec.rb b/spec/controllers/api/v1/timelines/direct_controller_spec.rb new file mode 100644 index 000000000..a22c2cbea --- /dev/null +++ b/spec/controllers/api/v1/timelines/direct_controller_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Api::V1::Timelines::DirectController, type: :controller do + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses') } + + describe 'GET #show' do + it 'returns 200' do + allow(controller).to receive(:doorkeeper_token) { token } + get :show + + expect(response).to have_http_status(200) + end + end +end -- cgit