blob_controller_spec.rb 921 Bytes
Newer Older
1 2
require 'spec_helper'

3
describe Projects::BlobController do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
4
  let(:project) { create(:project) }
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  let(:user)    { create(:user) }

  before do
    sign_in(user)

    project.team << [user, :master]

    project.stub(:branches).and_return(['master', 'foo/bar/baz'])
    project.stub(:tags).and_return(['v1.0.0', 'v2.0.0'])
    controller.instance_variable_set(:@project, project)
  end

  describe "GET show" do
    render_views

20
    before { get :show, project_id: project.to_param, id: id }
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

    context "valid branch, valid file" do
      let(:id) { 'master/README.md' }
      it { should respond_with(:success) }
    end

    context "valid branch, invalid file" do
      let(:id) { 'master/invalid-path.rb' }
      it { should respond_with(:not_found) }
    end

    context "invalid branch, valid file" do
      let(:id) { 'invalid-branch/README.md' }
      it { should respond_with(:not_found) }
    end
  end
end