From 7b7bf834e9f8616440259fcee518fa11adf3e457 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 18 Nov 2016 23:08:52 +0100 Subject: [PATCH] Fix OAuth authorization page and add a spec for it --- app/views/oauth/authorizations/new.html.haml | 2 +- spec/controllers/about_controller_spec.rb | 7 ++++++ spec/controllers/home_controller_spec.rb | 2 ++ .../oauth/authorizations_controller_spec.rb | 25 +++++++++++++++++++ spec/controllers/tags_controller_spec.rb | 2 +- .../services/fan_out_on_write_service_spec.rb | 6 ++--- 6 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 spec/controllers/oauth/authorizations_controller_spec.rb diff --git a/app/views/oauth/authorizations/new.html.haml b/app/views/oauth/authorizations/new.html.haml index cd6e93e08a..f058e2cce6 100644 --- a/app/views/oauth/authorizations/new.html.haml +++ b/app/views/oauth/authorizations/new.html.haml @@ -2,7 +2,7 @@ = t('doorkeeper.authorizations.new.title') .oauth-prompt - %h2= t('doorkeeper.authorizations.new.prompt', name: @pre_auth.client.name) + %h2= t('doorkeeper.authorizations.new.prompt', client_name: @pre_auth.client.name) %p = t('doorkeeper.authorizations.new.able_to') diff --git a/spec/controllers/about_controller_spec.rb b/spec/controllers/about_controller_spec.rb index 4fb58637af..4282649e1a 100644 --- a/spec/controllers/about_controller_spec.rb +++ b/spec/controllers/about_controller_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe AboutController, type: :controller do + render_views describe 'GET #index' do it 'returns http success' do @@ -9,4 +10,10 @@ RSpec.describe AboutController, type: :controller do end end + describe 'GET #terms' do + it 'returns http success' do + get :terms + expect(response).to have_http_status(:success) + end + end end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index ec2e3b67ca..0215495b74 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe HomeController, type: :controller do + render_views + describe 'GET #index' do it 'redirects to about page' do get :index diff --git a/spec/controllers/oauth/authorizations_controller_spec.rb b/spec/controllers/oauth/authorizations_controller_spec.rb new file mode 100644 index 0000000000..0e3b34bf07 --- /dev/null +++ b/spec/controllers/oauth/authorizations_controller_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +RSpec.describe Oauth::AuthorizationsController, type: :controller do + render_views + + let(:app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: 'http://localhost/') } + + before do + sign_in Fabricate(:user), scope: :user + end + + describe 'GET #new' do + before do + get :new, params: { client_id: app.uid, response_type: 'code', redirect_uri: 'http://localhost/' } + end + + it 'returns http success' do + expect(response).to have_http_status(:success) + end + + it 'gives options to authorize and deny' do + expect(response.body).to match(/Authorize/) + end + end +end diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 92e25e03b4..80007ecdad 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe TagsController, type: :controller do + render_views describe 'GET #show' do before do @@ -12,5 +13,4 @@ RSpec.describe TagsController, type: :controller do expect(response).to have_http_status(:success) end end - end diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb index 36bfcda161..e46a31c243 100644 --- a/spec/services/fan_out_on_write_service_spec.rb +++ b/spec/services/fan_out_on_write_service_spec.rb @@ -19,15 +19,15 @@ RSpec.describe FanOutOnWriteService do end it 'delivers status to home timeline' do - expect(Feed.new(:home, author).get(1).map(&:id)).to include status.id + expect(Feed.new(:home, author).get(10).map(&:id)).to include status.id end it 'delivers status to local followers' do - expect(Feed.new(:home, follower).get(1).map(&:id)).to include status.id + expect(Feed.new(:home, follower).get(10).map(&:id)).to include status.id end it 'delivers status to mentioned users' do - expect(Feed.new(:mentions, alice).get(1).map(&:id)).to include status.id + expect(Feed.new(:mentions, alice).get(10).map(&:id)).to include status.id end it 'delivers status to hashtag' do