summaryrefslogtreecommitdiff
path: root/spec/frontend/fixtures/labels.rb
blob: a312287970fdd5b64dfca1a856bd6176c15bac69 (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
require 'spec_helper'

describe 'Labels (JavaScript fixtures)' do
  include JavaScriptFixturesHelpers

  let(:admin) { create(:admin) }
  let(:group) { create(:group, name: 'frontend-fixtures-group' )}
  let(:project) { create(:project_empty_repo, namespace: group, path: 'labels-project') }

  let!(:project_label_bug) { create(:label, project: project, title: 'bug', color: '#FF0000') }
  let!(:project_label_enhancement) { create(:label, project: project, title: 'enhancement', color: '#00FF00') }
  let!(:project_label_feature) { create(:label, project: project, title: 'feature', color: '#0000FF') }

  let!(:group_label_roses) { create(:group_label, group: group, title: 'roses', color: '#FF0000') }
  let!(:groub_label_space) { create(:group_label, group: group, title: 'some space', color: '#FFFFFF') }
  let!(:groub_label_violets) { create(:group_label, group: group, title: 'violets', color: '#0000FF') }

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

  after do
    remove_repository(project)
  end

  describe Groups::LabelsController, '(JavaScript fixtures)', type: :controller do
    render_views

    before do
      sign_in(admin)
    end

    it 'labels/group_labels.json' do
      get :index, params: {
        group_id: group
      }, format: 'json'

      expect(response).to be_successful
    end
  end

  describe Projects::LabelsController, '(JavaScript fixtures)', type: :controller do
    render_views

    before do
      sign_in(admin)
    end

    it 'labels/project_labels.json' do
      get :index, params: {
        namespace_id: group,
        project_id: project
      }, format: 'json'

      expect(response).to be_successful
    end
  end
end