Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
2878c990
Commit
2878c990
authored
Jun 14, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure Todos counters doesn't count Todos for projects pending delete
parent
bb4a1ef6
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
23 deletions
+50
-23
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+8
-13
app/finders/todos_finder.rb
app/finders/todos_finder.rb
+1
-1
app/helpers/todos_helper.rb
app/helpers/todos_helper.rb
+2
-2
features/dashboard/todos.feature
features/dashboard/todos.feature
+6
-1
features/steps/dashboard/todos.rb
features/steps/dashboard/todos.rb
+29
-6
spec/features/todos/todos_spec.rb
spec/features/todos/todos_spec.rb
+4
-0
No files found.
app/controllers/dashboard/todos_controller.rb
View file @
2878c990
class
Dashboard::TodosController
<
Dashboard
::
ApplicationController
before_action
:find_todos
,
only:
[
:index
,
:destroy
,
:destroy_all
]
include
TodosHelper
before_action
:find_todos
,
only:
[
:index
,
:destroy_all
]
def
index
@todos
=
@todos
.
page
(
params
[
:page
])
...
...
@@ -8,14 +10,10 @@ class Dashboard::TodosController < Dashboard::ApplicationController
def
destroy
TodoService
.
new
.
mark_todos_as_done
([
todo
],
current_user
)
todo_notice
=
'Todo was successfully marked as done.'
respond_to
do
|
format
|
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
todo_notice
}
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
'Todo was successfully marked as done.'
}
format
.
js
{
head
:ok
}
format
.
json
do
render
json:
{
count:
@todos
.
size
,
done_count:
current_user
.
todos_done_count
}
end
format
.
json
{
render
json:
{
count:
todos_pending_count
,
done_count:
todos_done_count
}
}
end
end
...
...
@@ -25,20 +23,17 @@ class Dashboard::TodosController < Dashboard::ApplicationController
respond_to
do
|
format
|
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
'All todos were marked as done.'
}
format
.
js
{
head
:ok
}
format
.
json
do
find_todos
render
json:
{
count:
@todos
.
size
,
done_count:
current_user
.
todos_done_count
}
end
format
.
json
{
render
json:
{
count:
todos_pending_count
,
done_count:
todos_done_count
}
}
end
end
private
def
todo
@todo
||=
current_user
.
todos
.
find
(
params
[
:id
])
@todo
||=
find_
todos
.
find
(
params
[
:id
])
end
def
find_todos
@todos
=
TodosFinder
.
new
(
current_user
,
params
).
execute
@todos
||
=
TodosFinder
.
new
(
current_user
,
params
).
execute
end
end
app/finders/todos_finder.rb
View file @
2878c990
...
...
@@ -123,7 +123,7 @@ class TodosFinder
end
def
by_state
(
items
)
case
params
[
:state
]
case
params
[
:state
]
.
to_s
when
'done'
items
.
done
else
...
...
app/helpers/todos_helper.rb
View file @
2878c990
module
TodosHelper
def
todos_pending_count
current_user
.
todos_pending_
count
TodosFinder
.
new
(
current_user
,
state: :pending
).
execute
.
count
end
def
todos_done_count
current_user
.
todos_done_
count
TodosFinder
.
new
(
current_user
,
state: :done
).
execute
.
count
end
def
todo_action_name
(
todo
)
...
...
features/dashboard/todos.feature
View file @
2878c990
...
...
@@ -14,7 +14,12 @@ Feature: Dashboard Todos
Scenario
:
I
mark todos as done
Then
I should see todos assigned to me
And
I mark the todo as done
And
I click on the
"Done"
tab
Then
I should see the todo marked as done
@javascript
Scenario
:
I
mark all todos as done
Then
I should see todos assigned to me
And
I mark all todos as done
Then
I should see all todos marked as done
@javascript
...
...
features/steps/dashboard/todos.rb
View file @
2878c990
...
...
@@ -26,14 +26,15 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
end
step
'I should see todos assigned to me'
do
page
.
within
(
'.todos-pending-count'
)
{
expect
(
page
).
to
have_content
'4'
}
expect
(
page
).
to
have_content
'To do 4'
expect
(
page
).
to
have_content
'Done 0'
expect
(
page
).
to
have_link
project
.
name_with_namespace
should_see_todo
(
1
,
"John Doe assigned you merge request
#{
merge_request
.
to_reference
}
"
,
merge_request
.
title
)
should_see_todo
(
2
,
"John Doe mentioned you on issue #
#{
issue
.
iid
}
"
,
"
#{
current_user
.
to_reference
}
Wdyt?"
)
should_see_todo
(
3
,
"John Doe assigned you issue #
#{
issue
.
iid
}
"
,
issue
.
title
)
should_see_todo
(
4
,
"Mary Jane mentioned you on issue #
#{
issue
.
iid
}
"
,
issue
.
title
)
should_see_todo
(
2
,
"John Doe mentioned you on issue
#
{
issue
.
to_reference
}
"
,
"
#{
current_user
.
to_reference
}
Wdyt?"
)
should_see_todo
(
3
,
"John Doe assigned you issue
#
{
issue
.
to_reference
}
"
,
issue
.
title
)
should_see_todo
(
4
,
"Mary Jane mentioned you on issue
#
{
issue
.
to_reference
}
"
,
issue
.
title
)
end
step
'I mark the todo as done'
do
...
...
@@ -41,18 +42,40 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
click_link
'Done'
end
page
.
within
(
'.todos-pending-count'
)
{
expect
(
page
).
to
have_content
'3'
}
expect
(
page
).
to
have_content
'To do 3'
expect
(
page
).
to
have_content
'Done 1'
should_not_see_todo
"John Doe assigned you merge request
#{
merge_request
.
to_reference
}
"
end
step
'I click on the "Done" tab'
do
step
'I mark all todos as done'
do
click_link
'Mark all as done'
page
.
within
(
'.todos-pending-count'
)
{
expect
(
page
).
to
have_content
'0'
}
expect
(
page
).
to
have_content
'To do 0'
expect
(
page
).
to
have_content
'Done 4'
expect
(
page
).
not_to
have_link
project
.
name_with_namespace
should_not_see_todo
"John Doe assigned you merge request
#{
merge_request
.
to_reference
}
"
should_not_see_todo
"John Doe mentioned you on issue
#{
issue
.
to_reference
}
"
should_not_see_todo
"John Doe assigned you issue
#{
issue
.
to_reference
}
"
should_not_see_todo
"Mary Jane mentioned you on issue
#{
issue
.
to_reference
}
"
end
step
'I should see the todo marked as done'
do
click_link
'Done 1'
expect
(
page
).
to
have_link
project
.
name_with_namespace
should_see_todo
(
1
,
"John Doe assigned you merge request
#{
merge_request
.
to_reference
}
"
,
merge_request
.
title
,
false
)
end
step
'I should see all todos marked as done'
do
click_link
'Done 4'
expect
(
page
).
to
have_link
project
.
name_with_namespace
should_see_todo
(
1
,
"John Doe assigned you merge request
#{
merge_request
.
to_reference
}
"
,
merge_request
.
title
,
false
)
should_see_todo
(
2
,
"John Doe mentioned you on issue
#{
issue
.
to_reference
}
"
,
"
#{
current_user
.
to_reference
}
Wdyt?"
,
false
)
should_see_todo
(
3
,
"John Doe assigned you issue
#{
issue
.
to_reference
}
"
,
issue
.
title
,
false
)
should_see_todo
(
4
,
"Mary Jane mentioned you on issue
#{
issue
.
to_reference
}
"
,
issue
.
title
,
false
)
end
step
'I filter by "Enterprise"'
do
...
...
@@ -76,7 +99,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
end
step
'I should not see todos related to "Mary Jane" in the list'
do
should_not_see_todo
"Mary Jane mentioned you on issue #
#{
issue
.
iid
}
"
should_not_see_todo
"Mary Jane mentioned you on issue
#
{
issue
.
to_reference
}
"
end
step
'I should not see todos related to "Merge Requests" in the list'
do
...
...
@@ -85,7 +108,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
step
'I should not see todos related to "Assignments" in the list'
do
should_not_see_todo
"John Doe assigned you merge request
#{
merge_request
.
to_reference
}
"
should_not_see_todo
"John Doe assigned you issue #
#{
issue
.
iid
}
"
should_not_see_todo
"John Doe assigned you issue
#
{
issue
.
to_reference
}
"
end
step
'I click on the todo'
do
...
...
spec/features/todos/todos_spec.rb
View file @
2878c990
...
...
@@ -103,11 +103,15 @@ describe 'Dashboard Todos', feature: true do
before
do
deleted_project
=
create
(
:project
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
pending_delete:
true
)
create
(
:todo
,
:mentioned
,
user:
user
,
project:
deleted_project
,
target:
issue
,
author:
author
)
create
(
:todo
,
:mentioned
,
user:
user
,
project:
deleted_project
,
target:
issue
,
author:
author
,
state: :done
)
login_as
(
user
)
visit
dashboard_todos_path
end
it
'shows "All done" message'
do
within
(
'.todos-pending-count'
)
{
expect
(
page
).
to
have_content
'0'
}
expect
(
page
).
to
have_content
'To do 0'
expect
(
page
).
to
have_content
'Done 0'
expect
(
page
).
to
have_content
"You're all done!"
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment