BigW Consortium Gitlab

refs_controller_spec.rb 1.04 KB
Newer Older
1 2 3
require 'spec_helper'

describe Projects::RefsController do
4
  let(:project) { create(:project, :repository) }
5 6 7 8 9 10 11 12 13
  let(:user)    { create(:user) }

  before do
    sign_in(user)
    project.team << [user, :developer]
  end

  describe 'GET #logs_tree' do
    def default_get(format = :html)
14 15
      get :logs_tree,
          namespace_id: project.namespace.to_param,
16
          project_id: project,
17 18 19
          id: 'master',
          path: 'foo/bar/baz.html',
          format: format
20 21 22
    end

    def xhr_get(format = :html)
23 24 25
      xhr :get,
          :logs_tree,
          namespace_id: project.namespace.to_param,
26
          project_id: project, id: 'master',
27
          path: 'foo/bar/baz.html', format: format
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    end

    it 'never throws MissingTemplate' do
      expect { default_get }.not_to raise_error
      expect { xhr_get }.not_to raise_error
    end

    it 'renders 404 for non-JS requests' do
      xhr_get

      expect(response).to be_not_found
    end

    it 'renders JS' do
      xhr_get(:js)
      expect(response).to be_success
    end
  end
end