diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-26 23:55:21 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-26 23:56:53 +0200 |
commit | 7e14eefc819ce27f45406452a4f8e2039d0f0886 (patch) | |
tree | a58bb240cff3a247b154362a0106369789a04ad1 /spec/controllers/api | |
parent | 210362e66578dae32cbf169884d3c2905fe32cb7 (diff) |
Replace logo, fix #57 - delete/unreblog/unfavourite API, fix #45 - app
registration API
Diffstat (limited to 'spec/controllers/api')
-rw-r--r-- | spec/controllers/api/apps_controller_spec.rb | 26 | ||||
-rw-r--r-- | spec/controllers/api/statuses_controller_spec.rb | 58 |
2 files changed, 84 insertions, 0 deletions
diff --git a/spec/controllers/api/apps_controller_spec.rb b/spec/controllers/api/apps_controller_spec.rb new file mode 100644 index 000000000..ebadddde2 --- /dev/null +++ b/spec/controllers/api/apps_controller_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +RSpec.describe Api::AppsController, type: :controller do + render_views + + describe 'POST #create' do + before do + post :create, params: { name: 'Test app', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob' } + end + + it 'returns http success' do + expect(response).to have_http_status(:success) + end + + it 'creates an OAuth app' do + expect(Doorkeeper::Application.find_by(name: 'Test app')).to_not be nil + end + + it 'returns client ID and client secret' do + json = body_as_json + + expect(json[:client_id]).to_not be_blank + expect(json[:client_secret]).to_not be_blank + end + end +end diff --git a/spec/controllers/api/statuses_controller_spec.rb b/spec/controllers/api/statuses_controller_spec.rb index d02cc9b29..b1f0a7bcc 100644 --- a/spec/controllers/api/statuses_controller_spec.rb +++ b/spec/controllers/api/statuses_controller_spec.rb @@ -57,6 +57,22 @@ RSpec.describe Api::StatusesController, type: :controller do end end + describe 'DELETE #destroy' do + let(:status) { Fabricate(:status, account: user.account) } + + before do + post :destroy, params: { id: status.id } + end + + it 'returns http success' do + expect(response).to have_http_status(:success) + end + + it 'removes the status' do + expect(Status.find_by(id: status.id)).to be nil + end + end + describe 'POST #reblog' do let(:status) { Fabricate(:status, account: user.account) } @@ -85,6 +101,27 @@ RSpec.describe Api::StatusesController, type: :controller do end end + describe 'POST #unreblog' do + let(:status) { Fabricate(:status, account: user.account) } + + before do + post :reblog, params: { id: status.id } + post :unreblog, params: { id: status.id } + end + + it 'returns http success' do + expect(response).to have_http_status(:success) + end + + it 'updates the reblogs count' do + expect(status.reblogs_count).to eq 0 + end + + it 'updates the reblogged attribute' do + expect(user.account.reblogged?(status)).to be false + end + end + describe 'POST #favourite' do let(:status) { Fabricate(:status, account: user.account) } @@ -112,4 +149,25 @@ RSpec.describe Api::StatusesController, type: :controller do expect(hash_body[:favourited]).to be true end end + + describe 'POST #unfavourite' do + let(:status) { Fabricate(:status, account: user.account) } + + before do + post :favourite, params: { id: status.id } + post :unfavourite, params: { id: status.id } + end + + it 'returns http success' do + expect(response).to have_http_status(:success) + end + + it 'updates the favourites count' do + expect(status.favourites_count).to eq 0 + end + + it 'updates the favourited attribute' do + expect(user.account.favourited?(status)).to be false + end + end end |