Skip to content

Commit

Permalink
Merge pull request #3165 from projecthydra/backport_of_3164
Browse files Browse the repository at this point in the history
Backport of #3164 to 7.3-stable
  • Loading branch information
jcoyne committed Apr 26, 2017
2 parents 8bb4514 + 3b3848c commit 8be710f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/sufia/admin/admin_sets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def list_search_builder
end

def create_admin_set
AdminSetCreateService.new(@admin_set, current_user).create
AdminSetCreateService.new(@admin_set, current_user, params[:admin_set][:workflow_name]).create
end

def setup_form
Expand Down
2 changes: 1 addition & 1 deletion app/services/sufia/admin_set_create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.create_default!
def initialize(admin_set, creating_user, workflow_name)
@admin_set = admin_set
@creating_user = creating_user
@workflow_name = workflow_name
@workflow_name = workflow_name || AdminSet::DEFAULT_WORKFLOW_NAME
end

attr_reader :creating_user, :admin_set, :workflow_name
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/sufia/admin/admin_sets_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
let(:service) { instance_double(Sufia::AdminSetCreateService) }
before do
allow(Sufia::AdminSetCreateService).to receive(:new)
.with(AdminSet, user)
.with(an_instance_of(AdminSet), user, anything)
.and_return(service)
end

Expand Down
21 changes: 17 additions & 4 deletions spec/tasks/rake_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require 'rake'

describe "Rake tasks" do
before do
load_rake_environment [
File.expand_path("../../../tasks/sufia_user.rake", __FILE__),
File.expand_path("../../../lib/tasks/default_admin_set.rake", __FILE__)
]
end

describe "sufia:user:list_emails" do
let!(:user1) { FactoryGirl.create(:user) }
let!(:user2) { FactoryGirl.create(:user) }

before do
load_rake_environment [File.expand_path("../../../tasks/sufia_user.rake", __FILE__)]
end

it "creates a file" do
run_task "sufia:user:list_emails"
expect(File.exist?("user_emails.txt")).to be_truthy
Expand All @@ -24,4 +27,14 @@
File.delete("abc123.txt")
end
end

describe 'sufia:default_admin_set:create' do
before do
AdminSet.find(AdminSet::DEFAULT_ID).eradicate if AdminSet.exists?(AdminSet::DEFAULT_ID)
end

it 'creates the default AdminSet' do
expect { run_task 'sufia:default_admin_set:create' }.to change { AdminSet.count }.by(1)
end
end
end

0 comments on commit 8be710f

Please sign in to comment.