Skip to content

Commit

Permalink
Test with Rails 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed Mar 11, 2024
1 parent 9c87e5a commit a80b23f
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
matrix:
os: [ ubuntu-latest ]
ruby:
- 2.7
- '3.0'
- '3.1'
- '3.2'
Expand All @@ -30,6 +29,7 @@ jobs:
- gemfiles/rails_6_0.gemfile
- gemfiles/rails_6_1.gemfile
- gemfiles/rails_7_0.gemfile
- gemfiles/rails_7_1.gemfile
steps:
- name: Repo checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -65,6 +65,7 @@ jobs:
- gemfiles/rails_6_0.gemfile
- gemfiles/rails_6_1.gemfile
- gemfiles/rails_7_0.gemfile
- gemfiles/rails_7_1.gemfile
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
Expand Down
2 changes: 1 addition & 1 deletion app/views/doorkeeper/authorizations/form_post.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</header>

<%= form_tag @pre_auth.redirect_uri, method: :post, name: :redirect_form, authenticity_token: false do %>
<% @authorize_response.body.compact.each do |key, value| %>
<% @authorize_response&.body&.compact&.each do |key, value| %>
<%= hidden_field_tag key, value %>
<% end %>
<% end %>
Expand Down
22 changes: 22 additions & 0 deletions gemfiles/rails_7_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 7.1.0"
gem "rspec-core"
gem "rspec-expectations"
gem "rspec-mocks"
gem "rspec-rails", "~> 5.0"
gem "rspec-support"
gem "rubocop", "~> 1.4"
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "rubocop-rspec", require: false
gem "bcrypt", "~> 3.1", require: false
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
gem "sprockets-rails"
gem "sqlite3", "~> 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
gem "timecop"

gemspec path: "../"
4 changes: 3 additions & 1 deletion spec/controllers/application_metal_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

require "spec_helper_integration"

RSpec.describe Doorkeeper::ApplicationMetalController do
RSpec.describe Doorkeeper::ApplicationMetalController, type: :controller do
render_views

controller(described_class) do
def index
render json: {}, status: 200
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/applications_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

RSpec.describe Doorkeeper::ApplicationsController do
RSpec.describe Doorkeeper::ApplicationsController, type: :controller do
render_views

context "when JSON API used" do
Expand Down
20 changes: 11 additions & 9 deletions spec/controllers/authorizations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
RSpec.describe Doorkeeper::AuthorizationsController, type: :controller do
include AuthorizationRequestHelper

render_views

class ActionDispatch::TestResponse
def query_params
@query_params ||= begin
Expand Down Expand Up @@ -39,7 +41,7 @@ def query_params

allow(Doorkeeper.config).to receive(:grant_flows).and_return(["implicit"])
allow(Doorkeeper.config).to receive(:authenticate_resource_owner).and_return(->(_) { authenticator_method })
allow(controller).to receive(:authenticator_method).and_return(user)
allow(subject).to receive(:authenticator_method).and_return(user)
end

describe "POST #create" do
Expand All @@ -50,7 +52,7 @@ def query_params

it "redirects after authorization" do
expect(response).to be_redirect
expect(controller).to receive(:authenticator_method).at_most(:once)
expect(subject).to receive(:authenticator_method).at_most(:once)
end

it "redirects to client redirect uri" do
Expand Down Expand Up @@ -756,7 +758,7 @@ def query_params
let(:confidential_client) { true }

it "redirects immediately" do
expect(controller).not_to receive(:render)
expect(subject).not_to receive(:render)
expect(response).to be_redirect
expect(response.location).to match(/^#{client.redirect_uri}/)
end
Expand All @@ -771,7 +773,7 @@ def query_params

it "renders the new view" do
expect(response).to be_successful
expect(controller).to render_with :new
expect(subject).to render_with :new
end

it "doesn't issue a token" do
Expand Down Expand Up @@ -1268,13 +1270,13 @@ def query_params
describe "authorize response memoization" do
it "memoizes the result of the authorization" do
pre_auth = double(:pre_auth, authorizable?: true)
allow(controller).to receive(:pre_auth) { pre_auth }
allow(subject).to receive(:pre_auth) { pre_auth }
strategy = double(:strategy, authorize: true)
expect(strategy).to receive(:authorize).once
allow(controller).to receive(:strategy) { strategy }
allow(controller).to receive(:create) do
2.times { controller.send :authorize_response }
controller.render json: {}, status: :ok
allow(subject).to receive(:strategy) { strategy }
allow(subject).to receive(:create) do
2.times { subject.send :authorize_response }
subject.render json: {}, status: :ok
end

post :create
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/protected_resources_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def doorkeeper_forbidden_render_options(*); end
end

RSpec.describe "doorkeeper authorize filter" do
render_views

context "when accepts token code specified as" do
controller do
before_action :doorkeeper_authorize!
Expand Down
4 changes: 3 additions & 1 deletion spec/controllers/token_info_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

require "spec_helper"

RSpec.describe Doorkeeper::TokenInfoController do
RSpec.describe Doorkeeper::TokenInfoController, type: :controller do
render_views

describe "when requesting token info with valid token" do
let(:doorkeeper_token) { FactoryBot.create(:access_token) }

Expand Down
4 changes: 3 additions & 1 deletion spec/controllers/tokens_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

require "spec_helper"

RSpec.describe Doorkeeper::TokensController do
RSpec.describe Doorkeeper::TokensController, type: :controller do
render_views

subject(:json) { JSON.parse(response.body) }

let(:client) { FactoryBot.create :application }
Expand Down

0 comments on commit a80b23f

Please sign in to comment.