Sha256: 10ab16e4f029bbf570b18441d51263dcc04634160d44dd6406b55af8ffed8dd3

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'

describe Hyrax::PermissionsController do
  let(:user) { create(:user) }
  before { sign_in user }

  describe '#confirm' do
    let(:work) { create(:generic_work, user: user) }

    it 'draws the page' do
      get :confirm, params: { id: work }
      expect(response).to be_success
    end
  end

  describe '#copy' do
    let(:work) { create(:generic_work, user: user) }

    it 'adds a worker to the queue' do
      expect(VisibilityCopyJob).to receive(:perform_later).with(work)
      post :copy, params: { id: work }
      expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en')
      expect(flash[:notice]).to eq 'Updating file permissions. This may take a few minutes. You may want to refresh your browser or return to this record later to see the updated file permissions.'
    end
  end

  describe '#confirm_access' do
    let(:work) { create(:work_with_one_file, user: user) }

    it 'draws the page' do
      get :confirm_access, params: { id: work }
      expect(response).to be_success
    end
  end

  describe '#copy_access' do
    let(:work) { create(:work_with_one_file, user: user) }

    it 'adds a worker to the queue' do
      expect(VisibilityCopyJob).to receive(:perform_later).with(work)
      expect(InheritPermissionsJob).to receive(:perform_later).with(work)
      post :copy_access, params: { id: work }
      expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en')
      expect(flash[:notice]).to eq 'Updating file access levels. This may take a few minutes. ' \
                                   'You may want to refresh your browser or return to this record ' \
                                   'later to see the updated file access levels.'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
test_hyrax-0.0.1.alpha spec/controllers/hyrax/permissions_controller_spec.rb