Sha256: 78003a833440130036c4f6bdb449e630fde0251ae6cf4f443c0a4ee75f5f3ca1

Contents?: true

Size: 1.45 KB

Versions: 42

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe "/accounts/_account.html.erb" do
  let(:account) { Factory.stub(:account) }
  let(:edit_link) { %{href="#{edit_account_path(account)}"} }
  let(:user) { Factory.stub(:user) }

  before { view.stubs(:current_user => user) }

  def render_account
    render :partial => "accounts/account", :locals => { :account => account }
  end

  context "admin" do
    before do
      user.stubs(:admin_of? => true)
      render_account
    end

    it "links to edit the account" do
      rendered.should include(edit_link)
    end
  end

  context "non admin" do
    before do
      user.stubs(:admin_of? => false)
      render_account
    end

    it "links to edit the account" do
      rendered.should_not include(edit_link)
    end
  end

  context "with projects" do
    let(:project) { Factory.stub(:project, :name => 'Test Project') }
    before do
      account.stubs(:projects_visible_to => [project])
      render_account
    end

    it "finds visible projects" do
      account.should have_received(:projects_visible_to).with(user)
    end

    it "renders projects" do
      rendered.should include(project.name)
    end

    it "doesn't render the blank slate" do
      rendered.should_not include("blank_slate")
    end
  end

  context "without projects" do
    before do
      account.stubs(:projects_visible_to => [])
      render_account
    end

    it "renders the blank slate" do
      rendered.should include("blank_slate")
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
saucy-0.2.24 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.21 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.20 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.18 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.17 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.16 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.15 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.14 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.13 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.12 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.11 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.10 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.9 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.8.1 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.8 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.7 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.6.1 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.6 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.5 spec/views/accounts/_account.html.erb_spec.rb
saucy-0.2.4.1 spec/views/accounts/_account.html.erb_spec.rb