Skip to content

Commit

Permalink
Revert breaking changes from v0.15.1..v0.15.2
Browse files Browse the repository at this point in the history
  • Loading branch information
catks committed Jan 19, 2024
1 parent e762941 commit c8fce42
Show file tree
Hide file tree
Showing 25 changed files with 146 additions and 165 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* @toptal/coresmiths-team
# CI
.github/workflows/ @toptal/coresmiths-team
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ AllCops:
- 'log/**/*'
DisplayCopNames: true
TargetRubyVersion: 2.6
TargetRailsVersion: 5.1
NewCops: enable

Naming/FileName:
Expand Down
61 changes: 30 additions & 31 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Next
# master (not released yet)

## v0.15.3

Expand All @@ -8,134 +8,133 @@

* Remove `BA` prefix in granite action generator
* Remove automatic synchronization from `embeds_many`/`embeds_one` associated objects (`action.association`) to their appropriate virtual attribute (`action.attributes('association')`)
* Update minimum granite-form version to 0.3.0

## v0.15.0
# Version 0.15.0

* [BREAKING] Change form builder from ActiveData to Granite::Form. This means Granite no longer depends
on ActiveData, Granite::Form currently is a direct replacement for ActiveData that uses same syntax.
* Add support for detecting types of aliased attributes when using `represents`

## v0.14.2
# Version 0.14.2

* Fix error existence check on `Granite::Action#merge_errors` in Rails 6.1
* Add `Granite::Action.subject?` helper method
* Fix ActiveRecord::Enum handling with represents

## v0.14.1
# Version 0.14.1

* Introduce the ruby2_keywords (https://github.com/ruby/ruby2_keywords) gem in order
to provide compatibility with Ruby 3 for some internal methods

## v0.14.0
# Version 0.14.0

* Introduce instrumentation and RSpec matcher to check if action was performed:
https://toptal.github.io/granite/testing/#testing-composition
* Introduce `Action.with` as a more powerful replacement for `Action.as`, that allows passing more than
just performer: https://toptal.github.io/granite/#context-performer

## v0.13.0
# Version 0.13.0

* Fix Ruby 3 Warnings
* Improve how projector specs initialize controller to be more rails like and fix several issues.
* [BREAKING] As a result abstract actions/projectors will have to be initialized using `prepend_before` in projector specs.

## v0.12.1
# Version 0.12.1

* Fix parameterized precondition error messages not working in Ruby 3.

## v0.12.0
# Version 0.12.0

* Support for Rails 6.1 (via https://github.com/toptal/active_data fork)
* Support for Rails 7.0
* Fix `represents` with `default: false` not seeing any changes in model

## v0.11.1
# Version 0.11.1

* Make `assign_data` protected so that it can be called from other actions.

## v0.11.0
# Version 0.11.0

* [BREAKING] Implemented `assign_data`, which replaces `before_validation` as a way to set data for models before validations.
* Converted `represents` to use `assign_data`
* Fix dispatcher not working correctly with blank routes (e.g. `post :perform, as: ''`)

## v0.10.0
# Version 0.10.0

* Fix Ruby 2.7 and 3.0 compatibility issues

## v0.9.9
# Version 0.9.9

* Simplify translations code when expanding relative keys (`.key`)
* Fix one Ruby 3 incompatibility

## v0.9.8
# Version 0.9.8

* Extract `Granite::Util` which allows evaluating conditions

## v0.9.7
# Version 0.9.7

* fix `represents` to skip not defined attributes on the reference

## v0.9.6
# Version 0.9.6

* fix gemspec to include `config` directory
* update readme

## v0.9.5
# Version 0.9.5

* add rubocop config that can be included in projects using Granite

## v0.9.4
# Version 0.9.4

* fix documentation
* add Rails 6 support
* fix path helper to work with string arguments

## v0.9.3
# Version 0.9.3

* move `apply_association_changes!` to perform block

## v0.9.2
# Version 0.9.2

* `satisfy_preconditions` matcher supports composable matchers.

## v0.9.1
# Version 0.9.1

### Changes
## Changes

* `satisfy_preconditions` matcher supports regular expressions

### Bug fixes
## Bug fixes

* remove callback loop triggered by executing action in `after_commit` of another action

## v0.9.0
# Version 0.9.0

### Breaking Changes
## Breaking Changes

* nested executions of actions creates a proper nested transactions using `ActiveRecord::Base.transaction(requires_new: true)`. [See how it works at Nested Transaction section](https://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html)

* don't silence `Granite::Action::Rollback` error when there is no `ActiveRecord`

### Changes
## Changes

* introduced `after_commit` callback for actions

## v0.8.3
# Version 0.8.3

### Breaking Changes
## Breaking Changes

* `represents` attribute with a default value updates corresponding model's attribute even when action's attribute was not changed

* represented value of model goes through defaultize and typecaster

## v0.8.0
# Version 0.8.0

### Changes
## Changes

* `represents` supports `allow_nil` option

## v0.7.0
# Version 0.7.0

In the beginning was the Word, and the Word was **Granite**
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
git_source(:toptal) { |repo| "https://github.com/toptal/#{repo}.git" }

gem 'granite-form', '0.3.0'
gem 'granite-form', '0.1.1'

gemspec
4 changes: 0 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'bump/tasks'

RSpec::Core::RakeTask.new(:spec)

task default: :spec

Bump.tag_by_default = true
Bump.changelog = true
3 changes: 1 addition & 2 deletions granite.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.5'

s.add_runtime_dependency 'actionpack', '>= 5.1', '< 7.1'
s.add_runtime_dependency 'granite-form', '>= 0.3.0'
s.add_runtime_dependency 'granite-form'
s.add_runtime_dependency 'activesupport', '>= 5.1', '< 7.1'
s.add_runtime_dependency 'memoist', '~> 0.16'
s.add_runtime_dependency 'ruby2_keywords', '~> 0.0.5'

s.add_development_dependency 'activerecord'
s.add_development_dependency 'appraisal'
s.add_development_dependency 'bump'
s.add_development_dependency 'capybara', '~> 2.18'
s.add_development_dependency 'fuubar', '~> 2.0'
s.add_development_dependency 'pg', '< 2'
Expand Down
10 changes: 5 additions & 5 deletions lib/generators/granite_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ class GraniteGenerator < Rails::Generators::NamedBase
class_option :collection, type: :boolean, aliases: '-C', desc: 'Generate collection action'

def create_action
template 'granite_action.rb.erb', "apq/actions/#{file_path}.rb"
template 'granite_business_action.rb.erb', "apq/actions/#{class_path.join('/')}/business_action.rb" unless options.collection?
template 'granite_action.rb.erb', "apq/actions/ba/#{file_path}.rb"
template 'granite_business_action.rb.erb', "apq/actions/ba/#{class_path.join('/')}/business_action.rb" unless options.collection?
template 'granite_base_action.rb.erb', 'apq/actions/base_action.rb', skip: true
template 'granite_action_spec.rb.erb', "spec/apq/actions/#{file_path}_spec.rb"
empty_directory "apq/actions/#{file_path}/#{projector}" if projector
template 'granite_action_spec.rb.erb', "spec/apq/actions/ba/#{file_path}_spec.rb"
empty_directory "apq/actions/ba/#{file_path}/#{projector}" if projector
end

private
Expand All @@ -18,7 +18,7 @@ def base_class_name
if options.collection?
'BaseAction'
else
"#{class_path.join('/').camelize}::BusinessAction"
"BA::#{class_path.join('/').camelize}::BusinessAction"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/generators/templates/granite_action.rb.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class <%= class_name %> < <%= base_class_name %>
class BA::<%= class_name %> < <%= base_class_name %>
<% if projector -%>
projector :<%= projector %>

Expand Down
2 changes: 1 addition & 1 deletion lib/generators/templates/granite_action_spec.rb.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe <%= class_name %> do
RSpec.describe BA::<%= class_name %> do
<% if options.collection? -%>
subject(:action) { described_class.as(performer).new(attributes) }

Expand Down
2 changes: 1 addition & 1 deletion lib/generators/templates/granite_business_action.rb.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class <%= class_path.join('/').camelize %>::BusinessAction < BaseAction
class BA::<%= class_path.join('/').camelize %>::BusinessAction < BaseAction
subject :<%= subject_name %>
end
3 changes: 2 additions & 1 deletion lib/granite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def self.context
require 'granite/action'
require 'granite/projector'
require 'granite/routing'
require 'granite/rails' if defined?(Rails)
require 'granite/typecasters'
require 'granite/rails' if defined?(::Rails)

Granite::Form.base_concern = Granite::Base
1 change: 1 addition & 0 deletions lib/granite/action/performing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def performed?

def perform_action(raise_errors: false, **options)
result = run_callbacks(:execute_perform) do
apply_association_changes!
execute_perform!(**options)
end
@_action_performed = true
Expand Down
14 changes: 3 additions & 11 deletions lib/granite/action/types/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@ module Granite
class Action
module Types
class Collection
attr_reader :subtype_definition
attr_reader :subtype

def initialize(subtype_definition)
@subtype_definition = subtype_definition
end

def ensure_type(value)
if value.respond_to? :transform_values
value.transform_values { |v| subtype_definition.ensure_type(v) }
elsif value.respond_to?(:map)
value.map { |v| subtype_definition.ensure_type(v) }
end
def initialize(subtype)
@subtype = subtype
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/granite/base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'granite/form/model'
require 'granite/form/model/primary'
require 'granite/form/model/lifecycle'
require 'granite/form/model/associations'

require 'granite/translations'
Expand Down
Loading

0 comments on commit c8fce42

Please sign in to comment.