Skip to content

Commit

Permalink
Fix per-project counters for Dashboard filters
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
  • Loading branch information
dzaporozhets committed Dec 25, 2013
1 parent f6a4e56 commit 1a2e11c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
18 changes: 6 additions & 12 deletions app/helpers/dashboard_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@ def filter_path(entity, options={})
end

def entities_per_project(project, entity)
items = project.items_for(entity)

items = case params[:status]
when 'closed'
items.closed
when 'all'
items
else
items.opened
end

items.cared(current_user).count
case entity.to_sym
when :issue then @issues.where(project_id: project.id)
when :merge_request then @merge_requests.where(target_project_id: project.id)
else
[]
end.count
end
end
2 changes: 1 addition & 1 deletion app/views/shared/_filter.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Assigned to me
%li{class: ("active" if params[:scope] == 'authored')}
= link_to filter_path(entity, scope: 'authored') do
Authored by me
Created by me
%li{class: ("active" if params[:scope] == 'all')}
= link_to filter_path(entity, scope: 'all') do
All
Expand Down
2 changes: 1 addition & 1 deletion features/steps/dashboard/dashboard_issues.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DashboardIssues < Spinach::FeatureSteps

step 'I click "Authored by me" link' do
within ".scope-filter" do
click_link 'Authored by me'
click_link 'Created by me'
end
end

Expand Down
2 changes: 1 addition & 1 deletion features/steps/dashboard/dashboard_merge_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DashboardMergeRequests < Spinach::FeatureSteps

step 'I click "Authored by me" link' do
within ".scope-filter" do
click_link 'Authored by me'
click_link 'Created by me'
end
end

Expand Down

0 comments on commit 1a2e11c

Please sign in to comment.