BigW Consortium Gitlab

projects_tree_spec.rb 2.21 KB
Newer Older
gitlabhq committed
1 2 3 4 5 6 7
require 'spec_helper'

describe "Projects" do
  before { login_as :user }

  describe "GET /projects/tree" do
    describe "head" do
Nihad Abbasov committed
8
      before do
gitlabhq committed
9 10 11
        @project = Factory :project
        @project.add_access(@user, :read)

gitlabhq committed
12
        visit tree_project_ref_path(@project, @project.root_ref)
gitlabhq committed
13 14 15
      end

      it "should be correct path" do
gitlabhq committed
16
        current_path.should == tree_project_ref_path(@project, @project.root_ref)
gitlabhq committed
17 18 19 20 21 22
      end

      it_behaves_like :tree_view
    end

    describe ValidCommit::ID do
Nihad Abbasov committed
23
      before do
gitlabhq committed
24 25 26
        @project = Factory :project
        @project.add_access(@user, :read)

gitlabhq committed
27
        visit tree_project_ref_path(@project, ValidCommit::ID)
gitlabhq committed
28 29 30
      end

      it "should be correct path" do
gitlabhq committed
31
        current_path.should == tree_project_ref_path(@project, ValidCommit::ID)
gitlabhq committed
32 33 34 35 36 37 38
      end

      it_behaves_like :tree_view
      it_behaves_like :project_side_pane
    end

    describe "branch passed" do
Nihad Abbasov committed
39
      before do
gitlabhq committed
40 41 42
        @project = Factory :project
        @project.add_access(@user, :read)

gitlabhq committed
43
        visit tree_project_ref_path(@project, @project.root_ref)
gitlabhq committed
44 45 46
      end

      it "should be correct path" do
gitlabhq committed
47
        current_path.should ==  tree_project_ref_path(@project, @project.root_ref)
gitlabhq committed
48 49 50 51 52 53 54 55
      end

      it_behaves_like :tree_view
      it_behaves_like :project_side_pane
    end

    # TREE FILE PREVIEW
    describe "file preview" do
Nihad Abbasov committed
56
      before do
gitlabhq committed
57 58 59
        @project = Factory :project
        @project.add_access(@user, :read)

gitlabhq committed
60
        visit tree_project_ref_path(@project, @project.root_ref, :path => ".rvmrc")
gitlabhq committed
61 62 63
      end

      it "should be correct path" do
gitlabhq committed
64
        current_path.should == tree_project_ref_path(@project, @project.root_ref)
gitlabhq committed
65 66 67 68 69 70 71 72
      end

      it "should contain file view" do
        page.should have_content("rvm use 1.9.2@legit")
      end
    end
  end

Nihad Abbasov committed
73
  # RAW FILE
gitlabhq committed
74
  describe "GET /projects/blob" do
Nihad Abbasov committed
75
    before do
gitlabhq committed
76 77 78
      @project = Factory :project
      @project.add_access(@user, :read)

gitlabhq committed
79
      visit blob_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH)
gitlabhq committed
80 81 82
    end

    it "should be correct path" do
gitlabhq committed
83
      current_path.should == blob_project_ref_path(@project, ValidCommit::ID)
gitlabhq committed
84 85
    end

Nihad Abbasov committed
86
    it "raw file response" do
gitlabhq committed
87 88 89 90
      page.source.should == ValidCommit::BLOB_FILE
    end
  end
end