BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b888ed59
Unverified
Commit
b888ed59
authored
May 31, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issuables_helper_spec and added a test for issuable_app_data
parent
632d0c0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
23 deletions
+49
-23
issuables_helper.rb
app/helpers/issuables_helper.rb
+23
-23
issuables_helper_spec.rb
spec/helpers/issuables_helper_spec.rb
+26
-0
No files found.
app/helpers/issuables_helper.rb
View file @
b888ed59
...
@@ -199,6 +199,29 @@ module IssuablesHelper
...
@@ -199,6 +199,29 @@ module IssuablesHelper
issuable_filter_params
.
any?
{
|
k
|
params
.
key?
(
k
)
}
issuable_filter_params
.
any?
{
|
k
|
params
.
key?
(
k
)
}
end
end
def
issuable_app_data
(
project
,
issue
)
data
=
{
endpoint:
realtime_changes_namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
),
'can-update'
=>
can?
(
current_user
,
:update_issue
,
issue
).
to_s
,
'issuable-ref'
=>
issue
.
to_reference
||
''
}
updated_at_by
=
updated_at_by
(
issue
)
data
.
merge
(
updated_at_by
)
end
def
updated_at_by
(
issuable
)
return
{}
unless
issuable
.
is_edited?
{
updated_at:
issuable
.
updated_at
.
to_time
.
iso8601
,
updated_by:
{
name:
issuable
.
last_edited_by
.
name
,
path:
user_path
(
issuable
.
last_edited_by
)
}
}
end
private
private
def
sidebar_gutter_collapsed?
def
sidebar_gutter_collapsed?
...
@@ -273,27 +296,4 @@ module IssuablesHelper
...
@@ -273,27 +296,4 @@ module IssuablesHelper
container:
(
is_collapsed
?
'body'
:
nil
)
container:
(
is_collapsed
?
'body'
:
nil
)
}
}
end
end
def
issuable_app_data
(
project
,
issue
)
data
=
{
endpoint:
realtime_changes_namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
),
'can-update'
=>
can?
(
current_user
,
:update_issue
,
issue
).
to_s
,
'issuable-ref'
=>
issue
.
to_reference
||
''
}
updated_at_by
=
updated_at_by
(
issue
)
data
.
merge
(
updated_at_by
)
end
def
updated_at_by
(
issuable
)
return
{}
unless
issuable
.
is_edited?
{
updated_at:
issuable
.
updated_at
.
to_time
.
iso8601
,
updated_by:
{
name:
issuable
.
last_edited_by
.
name
,
path:
user_path
(
issuable
.
last_edited_by
)
}
}
end
end
end
spec/helpers/issuables_helper_spec.rb
View file @
b888ed59
...
@@ -193,6 +193,32 @@ describe IssuablesHelper do
...
@@ -193,6 +193,32 @@ describe IssuablesHelper do
end
end
end
end
describe
'#issuable_app_data'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
last_edited_by:
user
,
created_at:
3
.
days
.
ago
,
updated_at:
2
.
days
.
ago
,
last_edited_at:
2
.
days
.
ago
)
}
let
(
:issue_app_data
)
do
{
endpoint:
realtime_changes_namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
),
'can-update'
=>
"true"
,
'issuable-ref'
=>
issue
.
to_reference
||
''
,
updated_at:
issue
.
updated_at
.
to_time
.
iso8601
,
updated_by:
{
name:
user
.
name
,
path:
user_path
(
user
)
}
}
end
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
nil
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
nil
,
:update_issue
,
issue
).
and_return
(
true
)
end
it
{
expect
(
helper
.
issuable_app_data
(
issue
.
project
,
issue
)).
to
eq
(
issue_app_data
)
}
end
describe
'#updated_at_by'
do
describe
'#updated_at_by'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:unedited_issuable
)
{
create
(
:issue
)
}
let
(
:unedited_issuable
)
{
create
(
:issue
)
}
...
...
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