BigW Consortium Gitlab

issues.rb 1.71 KB
Newer Older
1 2 3 4 5 6
require 'spec_helper'

describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller do
  include JavaScriptFixturesHelpers

  let(:admin) { create(:admin) }
7 8
  let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
  let(:project) { create(:project_empty_repo, namespace: namespace, path: 'issues-project') }
9 10 11 12 13 14 15

  render_views

  before(:all) do
    clean_frontend_fixtures('issues/')
  end

16
  before do
17 18 19
    sign_in(admin)
  end

20 21 22 23
  after do
    remove_repository(project)
  end

24 25 26 27 28 29 30 31 32
  it 'issues/open-issue.html.raw' do |example|
    render_issue(example.description, create(:issue, project: project))
  end

  it 'issues/closed-issue.html.raw' do |example|
    render_issue(example.description, create(:closed_issue, project: project))
  end

  it 'issues/issue-with-task-list.html.raw' do |example|
33 34 35 36 37
    issue = create(:issue, project: project, description: '- [ ] Task List Item')
    render_issue(example.description, issue)
  end

  it 'issues/issue_with_comment.html.raw' do |example|
38
    issue = create(:issue, project: project)
39
    create(:note, project: project, noteable: issue, note: '- [ ] Task List Item').save
40 41 42
    render_issue(example.description, issue)
  end

43 44 45 46 47 48 49 50 51 52 53
  it 'issues/issue_list.html.raw' do |example|
    create(:issue, project: project)

    get :index,
      namespace_id: project.namespace.to_param,
      project_id: project

    expect(response).to be_success
    store_frontend_fixture(response, example.description)
  end

54 55 56 57 58
  private

  def render_issue(fixture_file_name, issue)
    get :show,
      namespace_id: project.namespace.to_param,
59
      project_id: project,
60 61 62 63 64 65
      id: issue.to_param

    expect(response).to be_success
    store_frontend_fixture(response, fixture_file_name)
  end
end