Sha256: fa4a8933cbbb100f44bbb33142169a3e0257687c2772a8d6cfc1606af3e8cbdf

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe '/_user_util_links.html.erb', type: :view do
  let(:join_date) { 5.days.ago }
  before do
    allow(view).to receive(:user_signed_in?).and_return(true)
    allow(view).to receive(:current_user).and_return(stub_model(User, user_key: 'userX'))
    allow(view).to receive(:can?).with(:create, GenericFile).and_return(can_create_file)
    assign :notify_number, 8
  end

  let(:can_create_file) { true }

  it 'has link to dashboard' do
    render
    page = Capybara::Node::Simple.new(rendered)
    expect(page).to have_link('userX', href: '/dashboard')
  end

  it 'has link to user profile' do
    render
    page = Capybara::Node::Simple.new(rendered)
    expect(page).to have_link('my profile', href: '/users/userX')
  end

  describe "upload button" do
    before do
      render
    end
    context "when the user can create generic files" do
      it "has a link to upload" do
        expect(rendered).to have_link('upload', href: '/files/new')
      end
    end
    context "when the user can't create generic files" do
      let(:can_create_file) { false }
      it "does not have a link to upload" do
        expect(rendered).not_to have_link('upload')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sufia-6.7.0 spec/views/users/_user_util_links.html.erb_spec.rb
sufia-6.6.1 spec/views/users/_user_util_links.html.erb_spec.rb
sufia-6.6.0 spec/views/users/_user_util_links.html.erb_spec.rb
sufia-6.5.0 spec/views/users/_user_util_links.html.erb_spec.rb
sufia-6.4.0 spec/views/users/_user_util_links.html.erb_spec.rb
sufia-6.3.0 spec/views/users/_user_util_links.html.erb_spec.rb