-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2090 from samvera/hyrax-5-clean-up-actors
🧹 Clean up actors
- Loading branch information
Showing
2 changed files
with
33 additions
and
11 deletions.
There are no files selected for viewing
18 changes: 7 additions & 11 deletions
18
app/actors/hyrax/environment.rb → app/actors/hyrax/environment_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
# OVERRIDE Hyrax 2.9 to add in import flag | ||
# OVERRIDE Hyrax v5.0.0rc2 to add in import flag | ||
|
||
module Hyrax | ||
module Actors | ||
class Environment | ||
module EnvironmentDecoractor | ||
# @param [ActiveFedora::Base] curation_concern work to operate on | ||
# @param [Ability] current_ability the authorizations of the acting user | ||
# @param [ActionController::Parameters] attributes user provided form attributes | ||
def initialize(curation_concern, current_ability, attributes, importing = false) | ||
@curation_concern = curation_concern | ||
@current_ability = current_ability | ||
@attributes = attributes.to_h.with_indifferent_access | ||
@importing = importing | ||
super(curation_concern, current_ability, attributes) | ||
end | ||
|
||
attr_reader :curation_concern, :current_ability, :attributes, :importing | ||
|
||
# @return [User] the user from the current_ability | ||
def user | ||
current_ability.current_user | ||
end | ||
attr_reader :importing | ||
end | ||
end | ||
end | ||
|
||
Hyrax::Actors::Environment.prepend(Hyrax::Actors::EnvironmentDecoractor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Hyrax::Actors::Environment, type: :decorator do | ||
let(:curation_concern) { double('curation_concern') } | ||
let(:current_ability) { double('current_ability') } | ||
let(:attributes) { {} } | ||
|
||
describe '#initialize' do | ||
context 'when importing is not explicitly set' do | ||
subject { described_class.new(curation_concern, current_ability, attributes) } | ||
|
||
it 'initializes with an importing flag set to false (default behavior)' do | ||
expect(subject.importing).to eq(false) | ||
end | ||
end | ||
|
||
context 'when importing is explicitly set' do | ||
let(:importing) { true } | ||
subject { described_class.new(curation_concern, current_ability, attributes, importing) } | ||
|
||
it 'initializes with an importing flag set to true' do | ||
expect(subject.importing).to eq(true) | ||
end | ||
end | ||
end | ||
end |