Skip to content

Commit

Permalink
Upgrade Doorkeeper version
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed Mar 25, 2024
1 parent ae87116 commit d313481
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 15 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ source "https://rubygems.org"

gemspec

gem "database_cleaner-mongoid"
gem "mongoid"
gem "rake"
gem "rspec-core"
gem "rspec-expectations"
gem "rspec-mocks"
gem "rspec-rails", "~> 4.0.0"
gem "rspec-rails", "~> 6.0.0"
gem "rspec-support"
gem "rubocop", "~> 1.29.1"
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "rubocop-rake", require: false
gem "rubocop-rspec", require: false
gem "sprockets-rails"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ variables defined in `.travis.yml` file.
To run locally, you need to choose a gemfile, with a command similar to:

```bash
$ export RAILS=5.1
$ export BUNDLE_GEMFILE=$PWD/gemfiles/Gemfile.mongoid6.rb
$ export RAILS=6.0
$ export BUNDLE_GEMFILE=$PWD/gemfiles/Gemfile.mongoid7.rb
```

---
Expand Down
18 changes: 14 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,34 @@
require "bundler/setup"
require "rspec/core/rake_task"

class ExtensionIntegrator
def self.gsub(filepath, pattern, value)
file = File.read(filepath)
updated_file = file.gsub(pattern, value)
File.open(filepath, 'w') { |line| line.puts(updated_file) }
end
end

task :load_doorkeeper do
`rm -rf spec/`
`git checkout spec`
unless Dir.exist?("doorkeeper")
`git submodule init`
`git submodule update`
if Dir["doorkeeper/*"].empty?
puts `git submodule init`
puts `git submodule update`
end
`cp -r -n doorkeeper/spec .`
`rm -rf spec/generators/` # we are not ActiveRecord
`rm -rf spec/validators/`
ExtensionIntegrator.gsub("spec/spec_helper.rb", 'require "database_cleaner"', "")
ExtensionIntegrator.gsub("spec/models/doorkeeper/application_spec.rb", 'context "when custom model class configured" do', 'xcontext "when custom model class configured" do')
`bundle exec rspec`
end

desc "Update Git submodules."
task :update_submodules do
Rake::Task["load_doorkeeper"].invoke if Dir["doorkeeper/*"].empty?

`git submodule foreach git pull origin master`
`git submodule foreach git pull origin main`
end

desc "Default: run specs."
Expand Down
2 changes: 1 addition & 1 deletion doorkeeper
Submodule doorkeeper updated 160 files
11 changes: 7 additions & 4 deletions doorkeeper-mongodb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ Gem::Specification.new do |gem|

gem.add_dependency "doorkeeper", ">= 5.2", "< 6.0"

gem.add_development_dependency "coveralls"
gem.add_development_dependency "database_cleaner", "~> 1.6.0"
gem.add_development_dependency "factory_bot", "~> 4.8"
gem.add_development_dependency "generator_spec", "~> 0.9.4"
gem.add_development_dependency "capybara"
gem.add_development_dependency "coveralls_reborn"
gem.add_development_dependency "database_cleaner-mongoid"
gem.add_development_dependency "factory_bot", "~> 6.0"
gem.add_development_dependency "generator_spec", "~> 0.10.0"
gem.add_development_dependency "grape"
gem.add_development_dependency "rake", ">= 11.3.0"
gem.add_development_dependency "rspec-rails"
gem.add_development_dependency "timecop"
end
4 changes: 3 additions & 1 deletion gemfiles/Gemfile.common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
gem "doorkeeper", "~> #{ENV.fetch("DOORKEEPER", "5.0")}"
gem "bcrypt"

gem "database_cleaner-mongoid"
gem "rspec-core"
gem "rspec-expectations"
gem "rspec-mocks"
gem "rspec-rails", "~> 4.0.0"
gem "rspec-rails", "~> 6.0.0"
gem "rspec-support"
gem "sprockets-rails"
19 changes: 19 additions & 0 deletions spec/dummy/config/mongoid8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
development:
clients:
default:
database: doorkeeper-mongoid8-development
hosts:
- localhost:27017
options:
write:
w: 1

test:
clients:
default:
database: doorkeeper-mongoid7-test
hosts:
- localhost:27017
options:
write:
w: 1
5 changes: 3 additions & 2 deletions spec/support/orm/mongoid.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true
require 'database_cleaner/mongoid'

DatabaseCleaner[:mongoid].strategy = :truncation
DatabaseCleaner[:mongoid].clean_with :truncation
DatabaseCleaner[:mongoid].strategy = :deletion
DatabaseCleaner[:mongoid].clean_with :deletion

# Monkey-patch for origin Doorkeeper specs that
# has `resource_owner.id + 1` :(
Expand Down
6 changes: 6 additions & 0 deletions spec/support/orm/mongoid8.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require_relative "mongoid"

Mongoid.logger.level = Logger::ERROR
Mongo::Logger.logger.level = Logger::ERROR

0 comments on commit d313481

Please sign in to comment.