registration API
This commit is contained in:
		
							
								
								
									
										26
									
								
								spec/controllers/api/apps_controller_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								spec/controllers/api/apps_controller_spec.rb
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
| @@ -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 | ||||
|   | ||||
| @@ -20,7 +20,7 @@ RSpec.describe Auth::SessionsController, type: :controller do | ||||
|       post :create, params: { user: { email: user.email, password: user.password } } | ||||
|     end | ||||
|  | ||||
|     it 'redirects to home page' do | ||||
|     it 'redirects to home' do | ||||
|       expect(response).to redirect_to(root_path) | ||||
|     end | ||||
|  | ||||
|   | ||||
| @@ -1,18 +0,0 @@ | ||||
| require 'rails_helper' | ||||
|  | ||||
| RSpec.describe Oauth::ApplicationsController, type: :controller do | ||||
|   before do | ||||
|     sign_in Fabricate(:user), scope: :user | ||||
|   end | ||||
|  | ||||
|   describe 'GET #index' do | ||||
|     it 'returns http success' do | ||||
|       get :index | ||||
|       expect(response).to have_http_status(:success) | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   describe 'POST #create' do | ||||
|     it 'redirects to the application page' | ||||
|   end | ||||
| end | ||||
							
								
								
									
										15
									
								
								spec/helpers/api/apps_helper_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								spec/helpers/api/apps_helper_spec.rb
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| require 'rails_helper' | ||||
|  | ||||
| # Specs in this file have access to a helper object that includes | ||||
| # the Api::AppsHelper. For example: | ||||
| # | ||||
| # describe Api::AppsHelper do | ||||
| #   describe "string concat" do | ||||
| #     it "concats two strings with spaces" do | ||||
| #       expect(helper.concat_strings("this","that")).to eq("this that") | ||||
| #     end | ||||
| #   end | ||||
| # end | ||||
| RSpec.describe Api::AppsHelper, type: :helper do | ||||
|   pending "add some examples to (or delete) #{__FILE__}" | ||||
| end | ||||
| @@ -1,5 +0,0 @@ | ||||
| require 'rails_helper' | ||||
|  | ||||
| RSpec.describe Oauth::ApplicationsHelper, type: :helper do | ||||
|  | ||||
| end | ||||
		Reference in New Issue
	
	Block a user