Fixed tests. Fixed overrided scope. Better usability for milestone view

This commit is contained in:
Dmitriy Zaporozhets 2013-06-17 11:57:37 +03:00
parent b1bdd82992
commit 2e839cee93
9 changed files with 68 additions and 49 deletions

View file

@ -1,7 +0,0 @@
$ ->
$('.milestone-merge-requests-filter li[data-closed]').addClass('hide')
$('.milestone-merge-requests-filter ul.nav li a').click ->
$('.milestone-merge-requests-filter li').toggleClass('active')
$('.milestone-merge-requests-filter li[data-closed]').toggleClass('hide')
false

View file

@ -8,7 +8,7 @@ module Issues
@issues = case params[:status]
when issues_filter[:all] then @project.issues
when issues_filter[:closed] then @project.issues.closed
when issues_filter[:to_me] then @project.issues.assigned(current_user)
when issues_filter[:to_me] then @project.issues.assigned_to(current_user)
when issues_filter[:by_me] then @project.issues.authored(current_user)
else @project.issues.opened
end

View file

@ -22,8 +22,10 @@ module Issuable
scope :closed, -> { with_state(:closed) }
scope :of_group, ->(group) { where(project_id: group.project_ids) }
scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) }
scope :assigned, ->(u) { where(assignee_id: u.id)}
scope :assigned_to, ->(u) { where(assignee_id: u.id)}
scope :recent, -> { order("created_at DESC") }
scope :assigned, -> { where("assignee_id IS NOT NULL") }
scope :unassigned, -> { where("assignee_id IS NULL") }
delegate :name,
:email,

View file

@ -28,8 +28,6 @@ class Issue < ActiveRecord::Base
scope :cared, ->(user) { where(assignee_id: user) }
scope :authored, ->(user) { where(author_id: user) }
scope :open_for, ->(user) { opened.assigned(user) }
scope :assigned, -> { where("assignee_id IS NOT NULL") }
scope :unassigned, -> { where("assignee_id IS NULL") }
state_machine :state, initial: :opened do
event :close do

View file

@ -1,10 +1,11 @@
.span6
.ui-box.milestone-issue-filter
%h5.title= title
%ul.well-list
- issues.each do |issue|
%li{data: {closed: issue.closed?}}
= link_to [@project, issue] do
%span.badge.badge-info ##{issue.id}
&ndash;
= link_to_gfm truncate(issue.title, length: 60), [@project, issue]
.ui-box
%h5.title= title
%ul.well-list
- issues.each do |issue|
%li
= link_to [@project, issue] do
%span.badge{class: issue.closed? ? 'badge-important' : 'badge-info'} ##{issue.id}
= link_to_gfm truncate(issue.title, length: 60), [@project, issue]
- if issue.assignee
.pull-right
= image_tag gravatar_icon(issue.assignee.email, 16), class: "avatar s16"

View file

@ -0,0 +1,5 @@
%li
= link_to [@project, merge_request] do
%span.badge.badge-info ##{merge_request.id}
&ndash;
= link_to_gfm truncate(merge_request.title, length: 60), [@project, merge_request]

View file

@ -55,32 +55,52 @@
= markdown @milestone.description
.row
= render(partial: 'issues', locals: {title: 'Unstarted Issues (open and unassigned)', issues: @issues.opened.unassigned})
%ul.nav.nav-tabs
%li.active
= link_to '#tab-issues', 'data-toggle' => 'tab' do
Issues
%span.badge= @issues.count
%li
= link_to '#tab-merge-requests', 'data-toggle' => 'tab' do
Merge Requests
%span.badge= @merge_requests.count
%li
= link_to '#tab-participants', 'data-toggle' => 'tab' do
Participants
%span.badge= @users.count
= render(partial: 'issues', locals: {title: 'Ongoing Issues (open and assigned)', issues: @issues.opened.assigned})
.row
.span6
.ui-box.milestone-merge-requests-filter
.title
%ul.nav.nav-pills
%li.active= link_to('Open Merge Requests', '#')
%li=link_to('All Merge Requests', '#')
%ul.well-list
- @merge_requests.each do |merge_request|
%li{data: {closed: merge_request.closed? || merge_request.merged?}}
= link_to [@project, merge_request] do
%span.badge.badge-info ##{merge_request.id}
&ndash;
= link_to_gfm truncate(merge_request.title, length: 60), [@project, merge_request]
.tab-content
.tab-pane.active#tab-issues
.row
.span4
= render('issues', title: 'Unstarted Issues (open and unassigned)', issues: @issues.opened.unassigned)
.span4
= render('issues', title: 'Ongoing Issues (open and assigned)', issues: @issues.opened.assigned)
.span4
= render('issues', title: 'Completed Issues (closed)', issues: @issues.closed)
= render(:partial => 'issues', locals: {title: 'Completed Issues (closed)', issues: @issues.closed})
.tab-pane#tab-merge-requests
.row
.span6
.ui-box
%h5.title Open
%ul.well-list
- @merge_requests.opened.each do |merge_request|
= render 'merge_request', merge_request: merge_request
.span6
.ui-box
%h5.title Closed
%ul.well-list
- @merge_requests.closed.each do |merge_request|
= render 'merge_request', merge_request: merge_request
%hr
%h6 Participants:
%div
- @users.each do |user|
= link_to_member(@project, user)
.clearfix
.tab-pane#tab-participants
%ul.bordered-list
- @users.each do |user|
%li
= link_to user, title: user.name, class: "dark" do
= image_tag gravatar_icon(user.email, 32), class: "avatar s32"
%strong= truncate(user.name, lenght: 40)
%br
%small.cgray= user.username

View file

@ -50,6 +50,6 @@ class ProjectMilestones < Spinach::FeatureSteps
end
Then "I should see 3 issues" do
page.should have_selector('.milestone-issue-filter .well-list li', count: 4)
page.should have_selector('#tab-issues li', count: 4)
end
end

View file

@ -93,7 +93,7 @@ class Userteams < Spinach::FeatureSteps
Then 'I should see issues from this team assigned to me' do
team = UserTeam.last
team.projects.each do |project|
project.issues.assigned(current_user).each do |issue|
project.issues.assigned_to(current_user).each do |issue|
page.should have_content issue.title
end
end
@ -121,7 +121,7 @@ class Userteams < Spinach::FeatureSteps
team = UserTeam.last
team.projects.each do |project|
team.members.each do |member|
project.issues.assigned(member).each do |issue|
project.issues.assigned_to(member).each do |issue|
page.should have_content issue.title
end
end