Sha256: 8d3161289cb3eb973f10b72ddabebb2d98f48938e67d92c3ae8a768e5c5bf013

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

RSpec.describe CurationConcerns::Workflow::GrantEditToDepositor do
  let(:depositor) { create(:user) }
  let(:user) { User.new }

  describe ".call" do
    subject do
      described_class.call(target: work,
                           comment: "A pleasant read",
                           user: user)
    end

    context "with no additional editors" do
      let(:work) { create(:work_without_access, depositor: depositor.user_key) }
      it "adds edit access" do
        expect { subject }.to change { work.edit_users }.from([]).to([depositor.user_key])
        expect(work).to be_valid
      end
    end

    context "with an additional editor" do
      let(:editor) { create(:user) }
      let(:work) { create(:work_without_access, depositor: depositor.user_key, edit_users: [editor.user_key]) }
      it "adds edit access" do
        expect { subject }.to change { work.edit_users }.from([editor.user_key]).to([editor.user_key, depositor.user_key])
        expect(work).to be_valid
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 spec/services/curation_concerns/workflow/grant_edit_to_depositor_spec.rb
curation_concerns-1.7.7 spec/services/curation_concerns/workflow/grant_edit_to_depositor_spec.rb
curation_concerns-2.0.0 spec/services/curation_concerns/workflow/grant_edit_to_depositor_spec.rb
curation_concerns-2.0.0.rc2 spec/services/curation_concerns/workflow/grant_edit_to_depositor_spec.rb