Sha256: f62699b8a9f2b323e2f3bfc3fa62fe1da3d9b8ed65c8a6a1973b0a4966c7c49c

Contents?: true

Size: 1.77 KB

Versions: 6

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe 'users/show.html.erb', type: :view do
  let(:join_date) { 5.days.ago }
  before do
    allow(view).to receive(:signed_in?).and_return(true)
    allow(view).to receive(:current_user).and_return(stub_model(User, user_key: 'mjg'))
    assign(:user, stub_model(User, user_key: 'cam156', created_at: join_date))
    assign(:followers, [])
    assign(:following, [])
    assign(:trophies, [])
    assign(:events, [])
  end

  it "draws 3 tabs" do
    render
    page = Capybara::Node::Simple.new(rendered)
    expect(page).to have_selector("ul#myTab.nav.nav-tabs > li > a[href='#contributions']")
    expect(page).to have_selector("ul#myTab.nav.nav-tabs > li > a[href='#profile']")
    expect(page).to have_selector("ul#myTab.nav.nav-tabs > li > a[href='#activity_log']")
    expect(page).to have_selector(".tab-content > div#contributions.tab-pane")
    expect(page).to have_selector(".tab-content > div#profile.tab-pane")
    expect(page).to have_selector(".tab-content > div#activity_log.tab-pane")
  end

  it "has the vitals" do
    render
    expect(rendered).to match(/Joined on #{join_date.strftime("%b %d, %Y")}/)
  end

  context "with trophy" do
    let(:generic_file) { stub_model(GenericFile, title: ["Fake object"], id: "abc123") }
    before do
      allow(view).to receive(:search_session).and_return({})
      allow(view).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
      allow(view).to receive(:current_search_session).and_return(nil)
      assign(:trophies, [generic_file])
    end

    it "has trophy" do
      render
      page = Capybara::Node::Simple.new(rendered)
      expect(page).to have_selector(".tab-content > div#contributions.tab-pane")
      expect(page).to have_selector("#trophyrow_#{generic_file.id}")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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