Commit 3dd7703b8083d44c64a03cef6b72d161aed04239

Authored by randx
1 parent 14bd9c92

Feature: Labels page. Index page

app/controllers/labels_controller.rb 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +class LabelsController < ApplicationController
  2 + before_filter :authenticate_user!
  3 + before_filter :project
  4 + before_filter :module_enabled
  5 +
  6 + layout "project"
  7 +
  8 + # Authorize
  9 + before_filter :add_project_abilities
  10 +
  11 + # Allow read any issue
  12 + before_filter :authorize_read_issue!
  13 +
  14 + respond_to :js, :html
  15 +
  16 + def index
  17 + @labels = Issue.tag_counts_on(:labels)
  18 + end
  19 +
  20 + protected
  21 +
  22 + def module_enabled
  23 + return render_404 unless @project.issues_enabled
  24 + end
  25 +end
... ...
app/views/issues/_head.html.haml
... ... @@ -5,6 +5,9 @@
5 5 %li{class: "#{'active' if current_page?(project_milestones_path(@project))}"}
6 6 = link_to project_milestones_path(@project), class: "tab" do
7 7 Milestones
  8 + %li{class: "#{'active' if current_page?(project_labels_path(@project))}"}
  9 + = link_to project_labels_path(@project), class: "tab" do
  10 + Labels
8 11 %li.right
9 12 %span.rss-icon
10 13 = link_to project_issues_path(@project, :atom, { private_token: current_user.private_token }) do
... ...
app/views/labels/_label.html.haml 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +%li.wll
  2 + %strong= label.name
  3 + .right
  4 + %span= pluralize label.count, 'issue'
... ...
app/views/labels/index.html.haml 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 += render "issues/head"
  2 +
  3 +%h3.page_title
  4 + Labels
  5 +%br
  6 +%div.ui-box
  7 + %ul.unstyled.labels-table
  8 + - @labels.each do |label|
  9 + = render 'label', label: label
  10 +
  11 + - unless @labels.present?
  12 + %li
  13 + %h3.nothing_here_message Nothing to show here
  14 +
... ...
config/routes.rb
... ... @@ -197,7 +197,9 @@ Gitlab::Application.routes.draw do
197 197 end
198 198 resources :team_members
199 199 resources :milestones
  200 + resources :labels, :only => [:index]
200 201 resources :issues do
  202 +
201 203 collection do
202 204 post :sort
203 205 post :bulk_update
... ...
features/projects/issues/labels.feature 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +Feature: Labels
  2 + Background:
  3 + Given I signin as a user
  4 + And I own project "Shop"
  5 + And project "Shop" have issues tags:
  6 + | name |
  7 + | bug |
  8 + | feature |
  9 + Given I visit project "Shop" labels page
  10 +
  11 + Scenario: I should see active milestones
  12 + Then I should see label "bug"
  13 + And I should see label "feature"
... ...
features/step_definitions/project/project_issues_steps.rb
... ... @@ -33,6 +33,25 @@ Given /^I visit issue page &quot;(.*?)&quot;$/ do |arg1|
33 33 end
34 34  
35 35 Given /^I submit new issue "(.*?)"$/ do |arg1|
36   - fill_in "issue_title", :with => arg1
  36 + fill_in "issue_title", with: arg1
37 37 click_button "Submit new issue"
38 38 end
  39 +
  40 +Given /^project "(.*?)" have issues tags:$/ do |arg1, table|
  41 + project = Project.find_by_name(arg1)
  42 + table.hashes.each do |hash|
  43 + Factory :issue,
  44 + project: project,
  45 + label_list: [hash[:name]]
  46 + end
  47 +end
  48 +
  49 +Given /^I visit project "(.*?)" labels page$/ do |arg1|
  50 + visit project_labels_path(Project.find_by_name(arg1))
  51 +end
  52 +
  53 +Then /^I should see label "(.*?)"$/ do |arg1|
  54 + within ".labels-table" do
  55 + page.should have_content arg1
  56 + end
  57 +end
... ...