summaryrefslogtreecommitdiff
path: root/spec/requests/projects_tree_spec.rb
blob: 4e3176bbdc3ca60dd9708a856d1b9c7065281de0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require 'spec_helper'

describe "Projects" do
  before { login_as :user }

  describe "GET /projects/tree" do
    describe "head" do
      before do 
        @project = Factory :project
        @project.add_access(@user, :read)

        visit tree_project_path(@project)
      end

      it "should be correct path" do
        current_path.should == tree_project_path(@project)
      end

      it_behaves_like :tree_view
    end

    describe ValidCommit::ID do
      before do 
        @project = Factory :project
        @project.add_access(@user, :read)

        visit tree_project_path(@project, :commit_id => ValidCommit::ID)
      end

      it "should be correct path" do
        current_path.should == tree_project_path(@project)
      end

      it_behaves_like :tree_view
      it_behaves_like :project_side_pane
    end

    describe "branch passed" do
      before do 
        @project = Factory :project
        @project.add_access(@user, :read)

        visit tree_project_path(@project, :branch => "master")
      end

      it "should be correct path" do
        current_path.should == tree_project_path(@project)
      end

      it_behaves_like :tree_view
      it_behaves_like :project_side_pane
    end

    # TREE FILE PREVIEW
    describe "file preview" do
      before do 
        @project = Factory :project
        @project.add_access(@user, :read)

        visit tree_project_path(@project, :path => ".rvmrc")
      end

      it "should be correct path" do
        current_path.should == tree_project_path(@project)
      end

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

  # RAW FILE 
  describe "GET /projects/blob" do
    before do 
      @project = Factory :project
      @project.add_access(@user, :read)

      visit blob_project_path(@project,
                              :path => ValidCommit::BLOB_FILE_PATH,
                              :commit_id => ValidCommit::ID)
    end

    it "should be correct path" do
      current_path.should == blob_project_path(@project)
    end

    it "raw file response" do 
      page.source.should == ValidCommit::BLOB_FILE
    end
  end
end