From 61d90f7ccae569fe18e54a7776e5d34270380898 Mon Sep 17 00:00:00 2001 From: Thomas McDonald Date: Thu, 3 Dec 2020 16:33:58 +0000 Subject: [PATCH 1/3] migrate CI to GitHub Actions (#552) * setup github actions * allow failure for mongoid 6 + 7 * add jobs for active record 6 * remove 2.3 and 2.4 from matrix * remove known failing instances * add ruby 2.7 as tested ruby * remove travis configuration --- .github/workflows/activerecord.yml | 27 ++++++++++++++++ .github/workflows/mongoid.yml | 32 ++++++++++++++++++ .travis.yml | 52 ------------------------------ Rakefile | 2 +- 4 files changed, 60 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/activerecord.yml create mode 100644 .github/workflows/mongoid.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/activerecord.yml b/.github/workflows/activerecord.yml new file mode 100644 index 00000000..2b3d2aee --- /dev/null +++ b/.github/workflows/activerecord.yml @@ -0,0 +1,27 @@ +name: activerecord +on: [push] +jobs: + ubuntu: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + gemfile: [activerecord_4, activerecord_5, activerecord_6] + ruby: [2.5.7, 2.6.5, 2.7.2] + env: + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + ADAPTER: active_record + steps: + - uses: actions/checkout@v2 + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - run: sudo apt-get install -y libsqlite3-dev + - run: gem update --system + - run: gem install bundler + - run: gem --version + - run: bundle install + - name: Run Tests + run: | + bundle exec rake diff --git a/.github/workflows/mongoid.yml b/.github/workflows/mongoid.yml new file mode 100644 index 00000000..175b89cb --- /dev/null +++ b/.github/workflows/mongoid.yml @@ -0,0 +1,32 @@ +name: mongoid +on: [push] +jobs: + ubuntu: + runs-on: ubuntu-latest + continue-on-error: true + services: + mongodb: + image: mongo:3.4.23 + ports: + - 27017:27017 + strategy: + matrix: + gemfile: [mongoid_5] + ruby: [2.5.7, 2.6.5, 2.7.2] + env: + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + ADAPTER: mongoid + steps: + - uses: actions/checkout@v2 + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - run: sudo apt-get install -y libsqlite3-dev + - run: gem update --system + - run: gem install bundler + - run: gem --version + - run: bundle install + - name: Run Tests + run: | + bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0fae3331..00000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -language: ruby - -before_install: - - gem update --system - - gem install bundler - - gem --version - -script: bundle exec rake - -after_success: - - bundle exec codeclimate-test-reporter - -rvm: - - 2.7.0 - - 2.6.3 - - 2.5.5 - -gemfile: - - gemfiles/activerecord_4.gemfile - - gemfiles/activerecord_5.gemfile - - gemfiles/activerecord_6.gemfile - - gemfiles/mongoid_5.gemfile - - gemfiles/mongoid_6.gemfile - - gemfiles/mongoid_7.gemfile - -env: - - ADAPTER=active_record - - ADAPTER=mongoid - -matrix: - exclude: - - gemfile: gemfiles/activerecord_4.gemfile - env: ADAPTER=mongoid - - gemfile: gemfiles/activerecord_5.gemfile - env: ADAPTER=mongoid - - gemfile: gemfiles/activerecord_6.gemfile - env: ADAPTER=mongoid - - gemfile: gemfiles/mongoid_5.gemfile - env: ADAPTER=active_record - - gemfile: gemfiles/mongoid_6.gemfile - env: ADAPTER=active_record - - gemfile: gemfiles/mongoid_7.gemfile - env: ADAPTER=active_record - allow_failures: - - gemfile: gemfiles/mongoid_6.gemfile - - gemfile: gemfiles/mongoid_7.gemfile - -services: mongodb - -addons: - code_climate: - repo_token: 6bd8d374b120a5449b9a4b7dfda40cc0609dbade48a1b6655f04a9bc8de3a3ee diff --git a/Rakefile b/Rakefile index 37774c2f..d4c22729 100644 --- a/Rakefile +++ b/Rakefile @@ -15,7 +15,7 @@ RSpec::Core::RakeTask.new(:rolify) do |task| task.pattern = 'spec/rolify/**/*_spec.rb' end -if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"] +if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"] task :default => :appraisal else task :default => [ :spec, 'coveralls:push' ] From 3871efbcc98d905398306f2ea3ca5f959e626867 Mon Sep 17 00:00:00 2001 From: Thomas McDonald Date: Sun, 25 Apr 2021 11:10:32 +0100 Subject: [PATCH 2/3] Prefer subquery over materialising list of roles (#559) Signed-off-by: Thomas McDonald Co-authored-by: Rafael Chiarello --- lib/rolify/adapters/active_record/resource_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rolify/adapters/active_record/resource_adapter.rb b/lib/rolify/adapters/active_record/resource_adapter.rb index aa18c3c7..c3dee94f 100644 --- a/lib/rolify/adapters/active_record/resource_adapter.rb +++ b/lib/rolify/adapters/active_record/resource_adapter.rb @@ -26,7 +26,7 @@ def resources_find(roles_table, relation, role_name) end def in(relation, user, role_names) - roles = user.roles.where(:name => role_names).select("#{quote_table(role_class.table_name)}.#{quote_column(role_class.primary_key)}").to_a + roles = user.roles.where(:name => role_names).select("#{quote_table(role_class.table_name)}.#{quote_column(role_class.primary_key)}") relation.where("#{quote_table(role_class.table_name)}.#{quote_column(role_class.primary_key)} IN (?) AND ((#{quote_table(role_class.table_name)}.resource_id = #{quote_table(relation.table_name)}.#{quote_column(relation.primary_key)}) OR (#{quote_table(role_class.table_name)}.resource_id IS NULL))", roles) end From c0f9d365df77396c8ddb470d1b2df44ca8ae947b Mon Sep 17 00:00:00 2001 From: Thomas McDonald Date: Sun, 25 Apr 2021 14:57:15 +0100 Subject: [PATCH 3/3] bump to version 6.0 --- CHANGELOG.rdoc | 11 +++++++++++ lib/rolify/version.rb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index da58883f..35a500db 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -1,3 +1,14 @@ += 6.0.0 (April 2, 2021) + +Breaking changes: + +* Support strict with_role queries. Note this changes behaviour of with_role when running in strict mode to behave as previously documented. #543 describes the behaviour change. +* Dropped support for Ruby 2.3 and 2.4 + +Improvements: + +* Updated ActiveRecord adapters implementation of in to utilise a subquery instead of two queries + = 5.3.0 (June 1, 2020) 5.3.0 will be the last version to support Ruby < 2.5 and Rails < 5.2. Support for these will be dropped in the next major release. diff --git a/lib/rolify/version.rb b/lib/rolify/version.rb index 83213139..86327cb3 100644 --- a/lib/rolify/version.rb +++ b/lib/rolify/version.rb @@ -1,3 +1,3 @@ module Rolify - VERSION = "5.3.0" + VERSION = "6.0.0" end