Sha256: 054b4fb3b46bc55ff8ecb7bd73640a277f54085f5806755df9f84416dad33cf3

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe 'curation_concerns/file_sets/_permission_form.html.erb', type: :view do
  let(:file_set) {
    stub_model(FileSet, id: '123',
                        depositor: 'bob',
                        resource_type: ['Dataset'])
  }

  let(:form) do
    view.simple_form_for(file_set, url: '/update') do |fs_form|
      return fs_form
    end
  end

  before do
    allow(controller).to receive(:current_user).and_return(stub_model(User))
    allow(file_set).to receive(:permissions).and_return(permissions)
    allow(view).to receive(:f).and_return(form)
    view.lookup_context.prefixes.push 'curation_concerns/base'
    render
  end

  context "without additional users" do
    let(:permissions) { [] }

    it "draws the permissions form without error" do
      expect(rendered).to have_css("input#new_user_name_skel")
      expect(rendered).not_to have_css("button.remove_perm")
    end
  end

  context "with additional users" do
    let(:depositor_permission) { Hydra::AccessControls::Permission.new(id: '123', name: 'bob', type: 'person', access: 'edit') }
    let(:public_permission) { Hydra::AccessControls::Permission.new(id: '124', name: 'public', type: 'group', access: 'read') }
    let(:other_permission) { Hydra::AccessControls::Permission.new(id: '125', name: 'joe@example.com', type: 'person', access: 'edit') }
    let(:permissions) { [depositor_permission, public_permission, other_permission] }

    it "draws the permissions form without error" do
      expect(rendered).to have_css("input#new_user_name_skel")
      expect(rendered).to have_css("button.remove_perm", count: 1) # depositor and public should be filtered out
      expect(rendered).to have_css("button.remove_perm[data-index='2']")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sufia-7.1.0 spec/views/curation_concerns/file_sets/_permission_form.html.erb_spec.rb
sufia-7.0.0 spec/views/curation_concerns/file_sets/_permission_form.html.erb_spec.rb
sufia-7.0.0.rc2 spec/views/curation_concerns/file_sets/_permission_form.html.erb_spec.rb
sufia-7.0.0.rc1 spec/views/curation_concerns/file_sets/_permission_form.html.erb_spec.rb
sufia-7.0.0.beta4 spec/views/curation_concerns/file_sets/_permission_form.html.erb_spec.rb
sufia-7.0.0.beta3 spec/views/curation_concerns/file_sets/_permission_form.html.erb_spec.rb
sufia-7.0.0.beta2 spec/views/curation_concerns/file_sets/_permission_form.html.erb_spec.rb
sufia-7.0.0.beta1 spec/views/curation_concerns/file_sets/_permission_form.html.erb_spec.rb