Skip to content

Commit

Permalink
chore(version): bump into 4.0.0
Browse files Browse the repository at this point in the history
- specify exact Rails 6.0 for testing
- add rails 7.1 for testing
- use yml instead of travis for testing
- test supermodel methods being modifiable
- test adjustable scoping
- test exists? method being correctly defined
- add find_or_initialize_by_spec test
- include models in migration spec
- minor modification in models and spec_helper
- added Eraser model for testing
- add many entities of Eraser inside the test when doing actables test
- safeguard scope to be options in actable
  • Loading branch information
bivanalhar authored and cysjonathan committed Jul 24, 2024
1 parent 784f4f8 commit 39cdc27
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 46 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby

on:
push:
branches: ['master']
pull_request:
branches: ['master']
schedule:
- cron: '0 0 * * 0'

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2']
activerecord: ['6.0', '6.1', '7.0', '7.1']
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.activerecord }}.gemfile
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

6 changes: 5 additions & 1 deletion Appraisals
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
appraise "rails-6.0" do
gem 'rails', '~> 6.0'
gem 'rails', '6.0.6.1'
end

appraise "rails-6.1" do
Expand All @@ -9,3 +9,7 @@ end
appraise "rails-7.0" do
gem 'rails', '~> 7.0'
end

appraise "rails-7.1" do
gem 'rails', '~> 7.1'
end
85 changes: 85 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,180 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [4.0.0] - 2024-06-03

### Added

- Add support for rails 6, 6.1, 7, 7.1 while removing rails 4.x and 5.x
from the travis matrix.
- Add support for ruby 3.0, 3.1, and 3.2
- Update test coverage
- Add `.exists?` support to seamlessly check in both the model and super model

### Fixed

- Bump minimum ruby version to 3.0
- Collection methods such as `<<` work now under rails 6.1
- Prepare for Rails 6.2 breaking change by updating how errors
are accessed and removing warning. They are now ruby objects.
see [this](https://api.rubyonrails.org/v6.1.0/classes/ActiveModel/Errors.html)
- Fixed rails `6.0.x` compatibility for `ActiveRecord::Errors`
- Handle kwargs in ruby 3 in methods delegated to supermodel
- Fix `.actables` to restrict based on type.

### Removed

- Remove last ruby 3 warnings and make the gem **totally compatible with
ruby 3**
- Remove support for rails 4.x and 5.x, as well as ruby 2.x

## [3.0.1] - 2018-04-25

### Changed

- Remove bi-directional autosave and use callbacks
- Ensure that non_cyclic_save does not get called for a new_record

## [3.0.0] - 2019-02-21

## [2.5.0] - 2017-07-29

### Changed

- Drop support for Rails >= 5.0
- Remove warnings occurring in Rails 5.1

## [2.4.2] - 2017-04-20

### Fixed

- Fix querying for conditions with hashes.

## [2.4.1] - 2017-04-19

### Fixed

- Make ActiveRecord::Relation#where! work.

## [2.4.0] - 2017-04-16

### Changed

- Don't make all supermodel class methods callable by submodel, only scopes. Add `callable_by_submodel` to supermodel so users can make their own class methods callable by submodels.

## [2.3.1] - 2017-04-15

### Fixed

- Make calling supermodel class methods work through relations/associations as well

## [2.3.0] - 2017-04-12

### Fixed

- Prevent duplicate validation errors (fixes https://github.com/krautcomputing/active_record-acts_as/issues/2)

### Added

- Added support for touching submodel attributes (https://github.com/krautcomputing/active_record-acts_as/pull/3, thanks to [dezmathio](https://github.com/dezmathio)!)

## [2.2.1] - 2017-04-08

### Fixed

- Make sure submodel instance changes are retained when calling `submodel_instance.acting_as.specific`

## [2.2.0] - 2017-04-08

### Added

- Added support for calling superclass methods on the subclass or subclass relations

## [2.1.1] - 2017-03-22

### Fixed

- Fix querying subclass with `where`, for `enum` (and possibly other) attributes the detection whether the attribute is defined on the superclass or subclass didn't work.

## [2.1.0] - 2017-03-17

### Added

- Access superobjects from query on submodel by calling `.actables`

## [2.0.9] - 2017-03-02

### Fixed

- Fix handling of query conditions that contain a dot

## [2.0.8] - 2017-02-17

### Fixed

- Avoid circular dependency on destroy

## [2.0.7] - 2017-02-17 [YANKED]

### Fixed

- Set reference to submodel when building supermodel

## [2.0.6] - 2017-02-17

### Added

- Allow arguments to #touch and forward them to the supermodel

## [2.0.5] - 2016-12-20

### Fixed

- Don't try to touch supermodel if it's not persisted
- Call `#destroy`, not `#delete`, on the submodule by default to trigger callbacks

## [2.0.4] - 2016-12-07

### Fixed

- Touch associated objects if supermodel is updated

## [2.0.3] - 2016-11-07

### Fixed

- Fix defining associations on `acting_as` model after calling `acting_as`

## [2.0.2] - 2016-11-06

### Fixed

- Call `#touch` on `actable` object when it's called on the `acting_as` object

## [2.0.1] - 2016-10-05

### Added

- Added this changelog
- Added `touch` option to skip touching the `acting_as` object (https://github.com/hzamani/active_record-acts_as/pull/78, thanks to [allenwq](https://github.com/allenwq)!)

## [2.0.0] - 2016-09-14

### Added

- Added support for Rails 5 (https://github.com/hzamani/active_record-acts_as/pull/80, thanks to [nicklandgrebe](https://github.com/nicklandgrebe)!)
- Allow specifying `association_method` parameter (https://github.com/hzamani/active_record-acts_as/pull/72, thanks to [tombowo](https://github.com/tombowo)!)

### Removed

- Dropped support for Ruby < 2.2 and ActiveSupport/ActiveRecord < 4.2

### Fixed

- Fixed `remove_actable` migration helper (https://github.com/hzamani/active_record-acts_as/pull/71, thanks to [nuclearpidgeon](https://github.com/nuclearpidgeon)!)

[Unreleased]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.4.2...HEAD
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
[![Coverage Status](https://coveralls.io/repos/krautcomputing/active_record-acts_as/badge.png)](https://coveralls.io/r/krautcomputing/active_record-acts_as)
[![Dependency Status](https://gemnasium.com/krautcomputing/active_record-acts_as.svg)](https://gemnasium.com/krautcomputing/active_record-acts_as)

# Change in the Upstream Repo

This branch, initially forked from [the fork of `hzamani`](https://github.com/hzamani/active_record-acts_as), has now been changed into [the fork of `manuelmeurer`](https://github.com/chaadow/active_record-acts_as) since the former repo has mentioned that the currently active development is taking place in the latter one. The latest update for this repo (v4.0.0) follows the version 5.2.0 of `manuelmeurer`'s repo.

# ActiveRecord::ActsAs

This is a refactor of [`acts_as_relation`](https://github.com/hzamani/acts_as_relation)
Expand All @@ -21,9 +25,9 @@ a separate table for each product type, i.e. a `pens` table with `color` column.

## Requirements

* Ruby >= 2.2
* ActiveSupport >= 4.2
* ActiveRecord >= 4.2
- Ruby >= 3.0, <= 3.2
- ActiveSupport >= 6.0, <= 7.1
- ActiveRecord >= 6.0, <= 7.1

## Installation

Expand Down Expand Up @@ -189,13 +193,11 @@ end

Multiple `acts_as` in the same class are not supported!


## Migrating from acts_as_relation

Replace `acts_as_superclass` in models with `actable` and if you where using
`:as_relation_superclass` option on `create_table` remove it and use `t.actable` on column definitions.


## RSpec custom matchers

To use this library custom RSpec matchers, you must require the `rspec/acts_as_matchers` file.
Expand Down
2 changes: 1 addition & 1 deletion active_record-acts_as.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = ">= 3.0"

spec.add_development_dependency "sqlite3"
spec.add_development_dependency "sqlite3", "~> 1.7"
spec.add_development_dependency "bundler"
spec.add_development_dependency "rspec", "~> 3"
spec.add_development_dependency "psych", "3.3.2"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
source "https://rubygems.org"

gem "coveralls", require: false
gem "rails", "~> 6.0"
gem "rails", "6.0.6.1"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "coveralls", require: false
gem "rails", "~> 7.1"

gemspec path: "../"
4 changes: 3 additions & 1 deletion lib/active_record/acts_as/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Relation
extend ActiveSupport::Concern

module ClassMethods
def acts_as(name, scope = nil, options = {})
def acts_as(name, scope = nil, **options)
options, scope = scope, nil if Hash === scope

association_method = options.delete(:association_method)
Expand Down Expand Up @@ -84,6 +84,8 @@ def is_a?(klass)
end

def actable(scope = nil, **options)
options, scope = scope, nil if Hash === scope

name = options.delete(:as) || :actable

reflections = belongs_to(name, scope, **options.reverse_merge(validate: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/active_record/acts_as/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ActiveRecord
module ActsAs
VERSION = "3.0.1"
VERSION = "4.0.0"
end
end
Loading

0 comments on commit 39cdc27

Please sign in to comment.