show.html.haml_spec.rb 1.3 KB
Newer Older
P
Phil Hughes 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
require 'spec_helper'

describe 'projects/commit/show.html.haml', :view do
  let(:project) { create(:project, :repository) }

  before do
    assign(:project, project)
    assign(:repository, project.repository)
    assign(:commit, project.commit)
    assign(:noteable, project.commit)
    assign(:notes, [])
    assign(:diffs, project.commit.diffs)

P
Phil Hughes 已提交
14
    allow(view).to receive(:current_user).and_return(nil)
P
Phil Hughes 已提交
15 16 17 18 19 20 21 22 23
    allow(view).to receive(:can?).and_return(false)
    allow(view).to receive(:can_collaborate_with_project?).and_return(false)
    allow(view).to receive(:current_ref).and_return(project.repository.root_ref)
    allow(view).to receive(:diff_btn).and_return('')
  end

  context 'inline diff view' do
    before do
      allow(view).to receive(:diff_view).and_return(:inline)
24
      allow(view).to receive(:diff_view).and_return(:inline)
P
Phil Hughes 已提交
25 26 27 28

      render
    end

29 30
    it 'has limited width' do
      expect(rendered).to have_selector('.limit-container-width')
P
Phil Hughes 已提交
31 32 33 34 35 36
    end
  end

  context 'parallel diff view' do
    before do
      allow(view).to receive(:diff_view).and_return(:parallel)
37
      allow(view).to receive(:fluid_layout).and_return(true)
P
Phil Hughes 已提交
38 39 40 41 42

      render
    end

    it 'spans full width' do
43
      expect(rendered).not_to have_selector('.limit-container-width')
P
Phil Hughes 已提交
44 45 46
    end
  end
end