-
Notifications
You must be signed in to change notification settings - Fork 27
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 #1084 from projecthydra/workflow_groups
Allow groups to be cast to Sipity::Agents
- Loading branch information
Showing
4 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
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,23 @@ | ||
module CurationConcerns | ||
class Group | ||
def initialize(name) | ||
@name = name | ||
end | ||
|
||
attr_reader :name | ||
|
||
def to_sipity_agent | ||
sipity_agent || create_sipity_agent! | ||
end | ||
|
||
private | ||
|
||
def sipity_agent | ||
Sipity::Agent.find_by(proxy_for_id: name, proxy_for_type: self.class.name) | ||
end | ||
|
||
def create_sipity_agent! | ||
Sipity::Agent.create!(proxy_for_id: name, proxy_for_type: self.class.name) | ||
end | ||
end | ||
end |
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
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,15 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe CurationConcerns::Group do | ||
let(:instance) { described_class.new('librarians') } | ||
let(:other_instance) { described_class.new('librarians') } | ||
|
||
describe "#to_sipity_agent" do | ||
it "is a Sipity::Agent" do | ||
expect(instance.to_sipity_agent).to be_kind_of Sipity::Agent | ||
end | ||
it "only creates one" do | ||
expect(instance.to_sipity_agent).to eq other_instance.to_sipity_agent | ||
end | ||
end | ||
end |
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