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
3c946b93
Commit
3c946b93
authored
Jul 17, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IssueNotesRefactor: Fix Rspec tests.
parent
72dfc763
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
45 deletions
+56
-45
app/assets/javascripts/notes/components/issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+20
-12
app/assets/javascripts/notes/components/issue_notes.vue
app/assets/javascripts/notes/components/issue_notes.vue
+2
-0
app/assets/javascripts/notes/index.js
app/assets/javascripts/notes/index.js
+16
-7
app/views/shared/issuable/_close_reopen_report_toggle.html.haml
...ews/shared/issuable/_close_reopen_report_toggle.html.haml
+1
-1
spec/features/issues/note_polling_spec.rb
spec/features/issues/note_polling_spec.rb
+4
-12
spec/support/features/discussion_comments_shared_example.rb
spec/support/features/discussion_comments_shared_example.rb
+13
-13
No files found.
app/assets/javascripts/notes/components/issue_comment_form.vue
View file @
3c946b93
...
@@ -45,6 +45,14 @@ export default {
...
@@ -45,6 +45,14 @@ export default {
return
this
.
isIssueOpen
?
'
Close issue
'
:
'
Reopen issue
'
;
return
this
.
isIssueOpen
?
'
Close issue
'
:
'
Reopen issue
'
;
},
},
actionButtonClassNames
()
{
return
{
'
btn-reopen
'
:
!
this
.
isIssueOpen
,
'
btn-close
'
:
this
.
isIssueOpen
,
'
js-note-target-close
'
:
this
.
isIssueOpen
,
'
js-note-target-reopen
'
:
!
this
.
isIssueOpen
,
}
},
},
},
methods
:
{
methods
:
{
handleSave
(
withIssueAction
)
{
handleSave
(
withIssueAction
)
{
...
@@ -173,8 +181,8 @@ export default {
...
@@ -173,8 +181,8 @@ export default {
@
keydown.meta.enter=
"handleSave()"
>
@
keydown.meta.enter=
"handleSave()"
>
</textarea>
</textarea>
</markdown-field>
</markdown-field>
<div
class=
"note-form-actions
clearfix
"
>
<div
class=
"note-form-actions"
>
<div
class=
"pull-left btn-group append-right-10 comment-type-dropdown js-comment-type-dropdown"
>
<div
class=
"pull-left btn-group append-right-10 comment-type-dropdown js-comment-type-dropdown
droplab-dropdown
"
>
<button
<button
@
click=
"handleSave()"
@
click=
"handleSave()"
:disabled=
"!note.length"
:disabled=
"!note.length"
...
@@ -196,41 +204,41 @@ export default {
...
@@ -196,41 +204,41 @@ export default {
<ul
<ul
class=
"note-type-dropdown dropdown-open-top dropdown-menu"
>
class=
"note-type-dropdown dropdown-open-top dropdown-menu"
>
<li
<li
:class=
"
{ 'item-selected': noteType === 'comment' }"
:class=
"
{ '
droplab-
item-selected': noteType === 'comment' }"
@click.prevent="setNoteType('comment')">
@click.prevent="setNoteType('comment')">
<
a
href=
"#
"
>
<
button
class=
"btn btn-transparent
"
>
<i
<i
aria-hidden=
"true"
aria-hidden=
"true"
class=
"fa fa-check"
></i>
class=
"fa fa-check
icon
"
></i>
<div
class=
"description"
>
<div
class=
"description"
>
<strong>
Comment
</strong>
<strong>
Comment
</strong>
<p>
<p>
Add a general comment to this issue.
Add a general comment to this issue.
</p>
</p>
</div>
</div>
</
a
>
</
button
>
</li>
</li>
<li
class=
"divider"
></li>
<li
class=
"divider
droplab-item-ignore
"
></li>
<li
<li
:class=
"
{ 'item-selected': noteType === 'discussion' }"
:class=
"
{ '
droplab-
item-selected': noteType === 'discussion' }"
@click.prevent="setNoteType('discussion')">
@click.prevent="setNoteType('discussion')">
<
a
href=
"#
"
>
<
button
class=
"btn btn-transparent
"
>
<i
<i
aria-hidden=
"true"
aria-hidden=
"true"
class=
"fa fa-check"
></i>
class=
"fa fa-check
icon
"
></i>
<div
class=
"description"
>
<div
class=
"description"
>
<strong>
Start discussion
</strong>
<strong>
Start discussion
</strong>
<p>
<p>
Discuss a specific suggestion or question.
Discuss a specific suggestion or question.
</p>
</p>
</div>
</div>
</
a
>
</
button
>
</li>
</li>
</ul>
</ul>
</div>
</div>
<a
<a
@
click=
"handleSave(true)"
@
click=
"handleSave(true)"
:class=
"
{'btn-reopen': !isIssueOpen, 'btn-close': isIssueOpen}
"
:class=
"
actionButtonClassNames
"
class=
"btn btn-nr btn-comment btn-comment-and-close"
class=
"btn btn-nr btn-comment btn-comment-and-close"
role=
"button"
>
role=
"button"
>
{{
issueActionButtonTitle
}}
{{
issueActionButtonTitle
}}
...
...
app/assets/javascripts/notes/components/issue_notes.vue
View file @
3c946b93
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
VueResource
from
'
vue-resource
'
;
import
storeOptions
from
'
../stores/issue_notes_store
'
;
import
storeOptions
from
'
../stores/issue_notes_store
'
;
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
import
IssueNote
from
'
./issue_note.vue
'
;
import
IssueNote
from
'
./issue_note.vue
'
;
...
@@ -13,6 +14,7 @@ import PlaceholderNote from './issue_placeholder_note.vue';
...
@@ -13,6 +14,7 @@ import PlaceholderNote from './issue_placeholder_note.vue';
import
PlaceholderSystemNote
from
'
./issue_placeholder_system_note.vue
'
;
import
PlaceholderSystemNote
from
'
./issue_placeholder_system_note.vue
'
;
Vue
.
use
(
Vuex
);
Vue
.
use
(
Vuex
);
Vue
.
use
(
VueResource
);
const
store
=
new
Vuex
.
Store
(
storeOptions
);
const
store
=
new
Vuex
.
Store
(
storeOptions
);
export
default
{
export
default
{
...
...
app/assets/javascripts/notes/index.js
View file @
3c946b93
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
IssueNotes
from
'
./components/issue_notes.vue
'
;
import
IssueNotes
from
'
./components/issue_notes.vue
'
;
import
'
../vue_shared/vue_resource_interceptor
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
new
Vue
({
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
el
:
'
#js-notes
'
,
const
vm
=
new
Vue
({
components
:
{
IssueNotes
},
el
:
'
#js-notes
'
,
template
:
`
components
:
{
IssueNotes
},
<issue-notes />
template
:
`
`
,
<issue-notes ref="notes" />
}));
`
,
});
window
.
issueNotes
=
{
refresh
()
{
vm
.
$refs
.
notes
.
$store
.
dispatch
(
'
poll
'
);
},
};
});
app/views/shared/issuable/_close_reopen_report_toggle.html.haml
View file @
3c946b93
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
-
button_action
=
issuable
.
closed?
?
'reopen'
:
'close'
-
button_action
=
issuable
.
closed?
?
'reopen'
:
'close'
-
display_button_action
=
button_action
.
capitalize
-
display_button_action
=
button_action
.
capitalize
-
button_responsive_class
=
'hidden-xs hidden-sm'
-
button_responsive_class
=
'hidden-xs hidden-sm'
-
button_class
=
"
#{
button_responsive_class
}
btn btn-grouped js-issuable-close-button issuable-close-button"
-
button_class
=
"
#{
button_responsive_class
}
btn btn-grouped js-issuable-close-button
js-btn-issue-action
issuable-close-button"
-
toggle_class
=
"
#{
button_responsive_class
}
btn btn-nr dropdown-toggle js-issuable-close-toggle"
-
toggle_class
=
"
#{
button_responsive_class
}
btn btn-nr dropdown-toggle js-issuable-close-toggle"
-
button_method
=
issuable_close_reopen_button_method
(
issuable
)
-
button_method
=
issuable_close_reopen_button_method
(
issuable
)
...
...
spec/features/issues/note_polling_spec.rb
View file @
3c946b93
...
@@ -13,7 +13,8 @@ feature 'Issue notes polling', :feature, :js do
...
@@ -13,7 +13,8 @@ feature 'Issue notes polling', :feature, :js do
it
'displays the new comment'
do
it
'displays the new comment'
do
note
=
create
(
:note
,
noteable:
issue
,
project:
project
,
note:
'Looks good!'
)
note
=
create
(
:note
,
noteable:
issue
,
project:
project
,
note:
'Looks good!'
)
page
.
execute_script
(
'notes.refresh();'
)
page
.
execute_script
(
'issueNotes.refresh();'
)
wait_for_requests
expect
(
page
).
to
have_selector
(
"#note_
#{
note
.
id
}
"
,
text:
'Looks good!'
)
expect
(
page
).
to
have_selector
(
"#note_
#{
note
.
id
}
"
,
text:
'Looks good!'
)
end
end
...
@@ -31,16 +32,6 @@ feature 'Issue notes polling', :feature, :js do
...
@@ -31,16 +32,6 @@ feature 'Issue notes polling', :feature, :js do
visit
project_issue_path
(
project
,
issue
)
visit
project_issue_path
(
project
,
issue
)
end
end
it
'has .original-note-content to compare against'
do
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
"
,
text:
note_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
count:
1
,
visible:
false
)
update_note
(
existing_note
,
updated_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
"
,
text:
updated_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
count:
1
,
visible:
false
)
end
it
'displays the updated content'
do
it
'displays the updated content'
do
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
"
,
text:
note_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
"
,
text:
note_text
)
...
@@ -127,7 +118,8 @@ feature 'Issue notes polling', :feature, :js do
...
@@ -127,7 +118,8 @@ feature 'Issue notes polling', :feature, :js do
def
update_note
(
note
,
new_text
)
def
update_note
(
note
,
new_text
)
note
.
update
(
note:
new_text
)
note
.
update
(
note:
new_text
)
page
.
execute_script
(
'notes.refresh();'
)
page
.
execute_script
(
'issueNotes.refresh();'
)
wait_for_requests
end
end
def
click_edit_action
(
note
)
def
click_edit_action
(
note
)
...
...
spec/support/features/discussion_comments_shared_example.rb
View file @
3c946b93
...
@@ -11,9 +11,10 @@ shared_examples 'discussion comments' do |resource_name|
...
@@ -11,9 +11,10 @@ shared_examples 'discussion comments' do |resource_name|
expect
(
page
).
to
have_selector
toggle_selector
expect
(
page
).
to
have_selector
toggle_selector
find
(
"
#{
form_selector
}
.note-textarea"
).
send_keys
(
'a'
)
find
(
"
#{
form_selector
}
.note-textarea"
).
send_keys
(
'a'
)
find
(
submit_selector
).
click
find
(
submit_selector
).
click
wait_for_requests
find
(
comments_selector
,
match: :first
)
find
(
comments_selector
,
match: :first
)
new_comment
=
all
(
comments_selector
).
last
new_comment
=
all
(
comments_selector
).
last
...
@@ -26,6 +27,7 @@ shared_examples 'discussion comments' do |resource_name|
...
@@ -26,6 +27,7 @@ shared_examples 'discussion comments' do |resource_name|
find
(
"
#{
form_selector
}
.note-textarea"
).
send_keys
(
'a'
)
find
(
"
#{
form_selector
}
.note-textarea"
).
send_keys
(
'a'
)
find
(
close_selector
).
click
find
(
close_selector
).
click
wait_for_requests
find
(
comments_selector
,
match: :first
)
find
(
comments_selector
,
match: :first
)
find
(
"
#{
comments_selector
}
.system-note"
)
find
(
"
#{
comments_selector
}
.system-note"
)
...
@@ -73,17 +75,17 @@ shared_examples 'discussion comments' do |resource_name|
...
@@ -73,17 +75,17 @@ shared_examples 'discussion comments' do |resource_name|
expect
(
page
).
not_to
have_selector
menu_selector
expect
(
page
).
not_to
have_selector
menu_selector
end
end
it
'clicking the ul padding or divider should not change the text'
do
#
it 'clicking the ul padding or divider should not change the text' do
find
(
menu_selector
).
trigger
'click'
#
find(menu_selector).trigger 'click'
expect
(
page
).
to
have_selector
menu_selector
#
expect(page).to have_selector menu_selector
expect
(
find
(
dropdown_selector
)).
to
have_content
'Comment'
#
expect(find(dropdown_selector)).to have_content 'Comment'
find
(
"
#{
menu_selector
}
.divider"
).
trigger
'click'
#
find("#{menu_selector} .divider").trigger 'click'
expect
(
page
).
to
have_selector
menu_selector
#
expect(page).to have_selector menu_selector
expect
(
find
(
dropdown_selector
)).
to
have_content
'Comment'
#
expect(find(dropdown_selector)).to have_content 'Comment'
end
#
end
describe
'when selecting "Start discussion"'
do
describe
'when selecting "Start discussion"'
do
before
do
before
do
...
@@ -91,9 +93,8 @@ shared_examples 'discussion comments' do |resource_name|
...
@@ -91,9 +93,8 @@ shared_examples 'discussion comments' do |resource_name|
all
(
"
#{
menu_selector
}
li"
).
last
.
click
all
(
"
#{
menu_selector
}
li"
).
last
.
click
end
end
it
'updates the submit button text
, note_type input
and closes the dropdown'
do
it
'updates the submit button text and closes the dropdown'
do
expect
(
find
(
dropdown_selector
)).
to
have_content
'Start discussion'
expect
(
find
(
dropdown_selector
)).
to
have_content
'Start discussion'
expect
(
find
(
"
#{
form_selector
}
#note_type"
,
visible:
false
).
value
).
to
eq
(
'DiscussionNote'
)
expect
(
page
).
not_to
have_selector
menu_selector
expect
(
page
).
not_to
have_selector
menu_selector
end
end
...
@@ -157,9 +158,8 @@ shared_examples 'discussion comments' do |resource_name|
...
@@ -157,9 +158,8 @@ shared_examples 'discussion comments' do |resource_name|
find
(
"
#{
menu_selector
}
li"
,
match: :first
).
click
find
(
"
#{
menu_selector
}
li"
,
match: :first
).
click
end
end
it
'updates the submit button text
, clears the note_type input
and closes the dropdown'
do
it
'updates the submit button text and closes the dropdown'
do
expect
(
find
(
dropdown_selector
)).
to
have_content
'Comment'
expect
(
find
(
dropdown_selector
)).
to
have_content
'Comment'
expect
(
find
(
"
#{
form_selector
}
#note_type"
,
visible:
false
).
value
).
to
eq
(
''
)
expect
(
page
).
not_to
have_selector
menu_selector
expect
(
page
).
not_to
have_selector
menu_selector
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