From d31348144198b520da86491038bde62b3a8bb809 Mon Sep 17 00:00:00 2001 From: Nikita Bulai Date: Mon, 25 Mar 2024 14:06:12 +0300 Subject: [PATCH] Upgrade Doorkeeper version --- Gemfile | 4 +++- README.md | 4 ++-- Rakefile | 18 ++++++++++++++---- doorkeeper | 2 +- doorkeeper-mongodb.gemspec | 11 +++++++---- gemfiles/Gemfile.common.rb | 4 +++- spec/dummy/config/mongoid8.yml | 19 +++++++++++++++++++ spec/support/orm/mongoid.rb | 5 +++-- spec/support/orm/mongoid8.rb | 6 ++++++ 9 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 spec/dummy/config/mongoid8.yml create mode 100644 spec/support/orm/mongoid8.rb diff --git a/Gemfile b/Gemfile index f3fd554..02b962c 100755 --- a/Gemfile +++ b/Gemfile @@ -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" \ No newline at end of file diff --git a/README.md b/README.md index a920386..d0f28f2 100644 --- a/README.md +++ b/README.md @@ -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 ``` --- diff --git a/Rakefile b/Rakefile index eeaa52b..f96c71d 100644 --- a/Rakefile +++ b/Rakefile @@ -3,16 +3,26 @@ 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 @@ -20,7 +30,7 @@ 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." diff --git a/doorkeeper b/doorkeeper index 88aea0f..e93f2d7 160000 --- a/doorkeeper +++ b/doorkeeper @@ -1 +1 @@ -Subproject commit 88aea0f7080eb6699cf80f9de57938b44eb28235 +Subproject commit e93f2d759ee14ce3c87c511d3498f73226d6ab46 diff --git a/doorkeeper-mongodb.gemspec b/doorkeeper-mongodb.gemspec index 63c7cd3..4d5374e 100644 --- a/doorkeeper-mongodb.gemspec +++ b/doorkeeper-mongodb.gemspec @@ -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 diff --git a/gemfiles/Gemfile.common.rb b/gemfiles/Gemfile.common.rb index 1e4b1fe..d91f85e 100644 --- a/gemfiles/Gemfile.common.rb +++ b/gemfiles/Gemfile.common.rb @@ -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" diff --git a/spec/dummy/config/mongoid8.yml b/spec/dummy/config/mongoid8.yml new file mode 100644 index 0000000..e5bc584 --- /dev/null +++ b/spec/dummy/config/mongoid8.yml @@ -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 diff --git a/spec/support/orm/mongoid.rb b/spec/support/orm/mongoid.rb index cdd543b..7cc5baf 100644 --- a/spec/support/orm/mongoid.rb +++ b/spec/support/orm/mongoid.rb @@ -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` :( diff --git a/spec/support/orm/mongoid8.rb b/spec/support/orm/mongoid8.rb new file mode 100644 index 0000000..9779410 --- /dev/null +++ b/spec/support/orm/mongoid8.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "mongoid" + +Mongoid.logger.level = Logger::ERROR +Mongo::Logger.logger.level = Logger::ERROR