issues_controller_spec.rb 1.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
require('spec_helper')

describe Projects::IssuesController do
  let(:project) { create(:project) }
  let(:user)    { create(:user) }
  let(:issue) { create(:issue, project: project) }

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

  describe "GET #index" do
    it "returns index" do
15
      get :index, namespace_id: project.namespace.path, project_id: project.path
16 17 18 19

      expect(response.status).to eq(200)
    end

20 21 22 23 24 25
    it "return 301 if request path doesn't match project path" do
      get :index, namespace_id: project.namespace.path, project_id: project.path.upcase

      expect(response).to redirect_to(namespace_project_issues_path(project.namespace, project))
    end

26 27 28 29
    it "returns 404 when issues are disabled" do
      project.issues_enabled = false
      project.save

30
      get :index, namespace_id: project.namespace.path, project_id: project.path
31 32 33 34
      expect(response.status).to eq(404)
    end

    it "returns 404 when external issue tracker is enabled" do
35
      controller.instance_variable_set(:@project, project)
36 37
      allow(project).to receive(:default_issues_tracker?).and_return(false)

38
      get :index, namespace_id: project.namespace.path, project_id: project.path
39 40 41 42 43
      expect(response.status).to eq(404)
    end

  end
end