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
Boxiang Sun
gitlab-ce
Commits
9651521e
Commit
9651521e
authored
Jun 22, 2017
by
Alexander Randa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace 'snippets/snippets.feature' spinach with rspec
parent
11716f31
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
57 additions
and
207 deletions
+57
-207
changelogs/unreleased/23036-replace-snippets-spinach.yml
changelogs/unreleased/23036-replace-snippets-spinach.yml
+4
-0
features/snippets/snippets.feature
features/snippets/snippets.feature
+0
-40
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+0
-4
features/steps/shared/snippet.rb
features/steps/shared/snippet.rb
+0
-63
features/steps/snippets/snippets.rb
features/steps/snippets/snippets.rb
+0
-86
spec/factories/personal_snippets.rb
spec/factories/personal_snippets.rb
+0
-4
spec/factories/project_snippets.rb
spec/factories/project_snippets.rb
+0
-5
spec/factories/snippets.rb
spec/factories/snippets.rb
+7
-0
spec/features/snippets/user_creates_snippet_spec.rb
spec/features/snippets/user_creates_snippet_spec.rb
+4
-2
spec/features/snippets/user_deletes_snippet_spec.rb
spec/features/snippets/user_deletes_snippet_spec.rb
+19
-0
spec/features/snippets/user_edits_snippet_spec.rb
spec/features/snippets/user_edits_snippet_spec.rb
+23
-3
No files found.
changelogs/unreleased/23036-replace-snippets-spinach.yml
0 → 100644
View file @
9651521e
---
title
:
Replace 'snippets/snippets.feature' spinach with rspec
merge_request
:
12385
author
:
Alexander Randa @randaalex
features/snippets/snippets.feature
deleted
100644 → 0
View file @
11716f31
@snippets
Feature
:
Snippets
Background
:
Given
I sign in as a user
And
I have public
"Personal snippet one"
snippet
And
I have private
"Personal snippet private"
snippet
@javascript
Scenario
:
I
create new snippet
Given
I visit new snippet page
And
I submit new snippet
"Personal snippet three"
Then
I should see snippet
"Personal snippet three"
Scenario
:
I
update
"Personal snippet one"
Given
I visit snippet page
"Personal snippet one"
And
I click link
"Edit"
And
I submit new title
"Personal snippet new title"
Then
I should see
"Personal snippet new title"
Scenario
:
Set "Personal snippet one" public
Given
I visit snippet page
"Personal snippet one"
And
I click link
"Edit"
And
I uncheck
"Private"
checkbox
Then
I should see
"Personal snippet one"
public
Scenario
:
I
destroy
"Personal snippet one"
Given
I visit snippet page
"Personal snippet one"
And
I click link
"Delete"
Then
I should not see
"Personal snippet one"
in snippets
Scenario
:
I
create new internal snippet
Given
I logout directly
And
I sign in as an admin
Then
I visit new snippet page
And
I submit new internal snippet
Then
I visit snippet page
"Internal personal snippet one"
And
I logout directly
Then
I sign in as a user
Given
I visit new snippet page
Then
I visit snippet page
"Internal personal snippet one"
features/steps/shared/paths.rb
View file @
9651521e
...
@@ -491,10 +491,6 @@ module SharedPaths
...
@@ -491,10 +491,6 @@ module SharedPaths
visit
explore_snippets_path
visit
explore_snippets_path
end
end
step
'I visit new snippet page'
do
visit
new_snippet_path
end
def
root_ref
def
root_ref
@project
.
repository
.
root_ref
@project
.
repository
.
root_ref
end
end
...
...
features/steps/shared/snippet.rb
deleted
100644 → 0
View file @
11716f31
module
SharedSnippet
include
Spinach
::
DSL
step
'I have public "Personal snippet one" snippet'
do
create
(
:personal_snippet
,
title:
"Personal snippet one"
,
content:
"Test content"
,
file_name:
"snippet.rb"
,
visibility_level:
Snippet
::
PUBLIC
,
author:
current_user
)
end
step
'I have private "Personal snippet private" snippet'
do
create
(
:personal_snippet
,
title:
"Personal snippet private"
,
content:
"Provate content"
,
file_name:
"private_snippet.rb"
,
visibility_level:
Snippet
::
PRIVATE
,
author:
current_user
)
end
step
'I have internal "Personal snippet internal" snippet'
do
create
(
:personal_snippet
,
title:
"Personal snippet internal"
,
content:
"Provate content"
,
file_name:
"internal_snippet.rb"
,
visibility_level:
Snippet
::
INTERNAL
,
author:
current_user
)
end
step
'I have a public many lined snippet'
do
create
(
:personal_snippet
,
title:
'Many lined snippet'
,
content:
<<-
END
.
gsub
(
/^\s+\|/
,
''
),
|line one
|line two
|line three
|line four
|line five
|line six
|line seven
|line eight
|line nine
|line ten
|line eleven
|line twelve
|line thirteen
|line fourteen
END
file_name:
'many_lined_snippet.rb'
,
visibility_level:
Snippet
::
PUBLIC
,
author:
current_user
)
end
step
'There is public "Personal snippet one" snippet'
do
create
(
:personal_snippet
,
title:
"Personal snippet one"
,
content:
"Test content"
,
file_name:
"snippet.rb"
,
visibility_level:
Snippet
::
PUBLIC
,
author:
create
(
:user
))
end
end
features/steps/snippets/snippets.rb
deleted
100644 → 0
View file @
11716f31
class
Spinach::Features::Snippets
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedPaths
include
SharedProject
include
SharedSnippet
include
WaitForRequests
step
'I click link "Personal snippet one"'
do
click_link
"Personal snippet one"
end
step
'I should not see "Personal snippet one" in snippets'
do
expect
(
page
).
not_to
have_content
"Personal snippet one"
end
step
'I click link "Edit"'
do
page
.
within
".detail-page-header"
do
first
(
:link
,
"Edit"
).
click
end
end
step
'I click link "Delete"'
do
first
(
:link
,
"Delete"
).
click
end
step
'I submit new snippet "Personal snippet three"'
do
fill_in
"personal_snippet_title"
,
with:
"Personal snippet three"
fill_in
"personal_snippet_file_name"
,
with:
"my_snippet.rb"
page
.
within
(
'.file-editor'
)
do
find
(
'.ace_editor'
).
native
.
send_keys
'Content of snippet three'
end
click_button
"Create snippet"
wait_for_requests
end
step
'I submit new internal snippet'
do
fill_in
"personal_snippet_title"
,
with:
"Internal personal snippet one"
fill_in
"personal_snippet_file_name"
,
with:
"my_snippet.rb"
choose
'personal_snippet_visibility_level_10'
page
.
within
(
'.file-editor'
)
do
find
(
:xpath
,
"//input[@id='personal_snippet_content']"
).
set
'Content of internal snippet'
end
click_button
"Create snippet"
end
step
'I should see snippet "Personal snippet three"'
do
expect
(
page
).
to
have_content
"Personal snippet three"
expect
(
page
).
to
have_content
"Content of snippet three"
end
step
'I submit new title "Personal snippet new title"'
do
fill_in
"personal_snippet_title"
,
with:
"Personal snippet new title"
click_button
"Save"
end
step
'I should see "Personal snippet new title"'
do
expect
(
page
).
to
have_content
"Personal snippet new title"
end
step
'I uncheck "Private" checkbox'
do
choose
"Internal"
click_button
"Save"
end
step
'I should see "Personal snippet one" public'
do
expect
(
page
).
to
have_no_xpath
(
"//i[@class='public-snippet']"
)
end
step
'I visit snippet page "Personal snippet one"'
do
visit
snippet_path
(
snippet
)
end
step
'I visit snippet page "Internal personal snippet one"'
do
visit
snippet_path
(
internal_snippet
)
end
def
snippet
@snippet
||=
PersonalSnippet
.
find_by!
(
title:
"Personal snippet one"
)
end
def
internal_snippet
@snippet
||=
PersonalSnippet
.
find_by!
(
title:
"Internal personal snippet one"
)
end
end
spec/factories/personal_snippets.rb
deleted
100644 → 0
View file @
11716f31
FactoryGirl
.
define
do
factory
:personal_snippet
,
parent: :snippet
,
class: :PersonalSnippet
do
end
end
spec/factories/project_snippets.rb
deleted
100644 → 0
View file @
11716f31
FactoryGirl
.
define
do
factory
:project_snippet
,
parent: :snippet
,
class: :ProjectSnippet
do
project
factory: :empty_project
end
end
spec/factories/snippets.rb
View file @
9651521e
...
@@ -18,4 +18,11 @@ FactoryGirl.define do
...
@@ -18,4 +18,11 @@ FactoryGirl.define do
visibility_level
Snippet
::
PRIVATE
visibility_level
Snippet
::
PRIVATE
end
end
end
end
factory
:project_snippet
,
parent: :snippet
,
class: :ProjectSnippet
do
project
factory: :empty_project
end
factory
:personal_snippet
,
parent: :snippet
,
class: :PersonalSnippet
do
end
end
end
spec/features/snippets/
create
_snippet_spec.rb
→
spec/features/snippets/
user_creates
_snippet_spec.rb
View file @
9651521e
require
'rails_helper'
require
'rails_helper'
feature
'
Create S
nippet'
,
:js
,
feature:
true
do
feature
'
User creates s
nippet'
,
:js
,
feature:
true
do
include
DropzoneHelper
include
DropzoneHelper
let
(
:user
)
{
create
(
:user
)
}
before
do
before
do
gitlab_sign_in
:user
sign_in
(
user
)
visit
new_snippet_path
visit
new_snippet_path
end
end
...
...
spec/features/snippets/user_deletes_snippet_spec.rb
0 → 100644
View file @
9651521e
require
'rails_helper'
feature
'User deletes snippet'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:content
)
{
'puts "test"'
}
let
(
:snippet
)
{
create
(
:personal_snippet
,
:public
,
content:
content
,
author:
user
)
}
before
do
sign_in
(
user
)
visit
snippet_path
(
snippet
)
end
it
'deletes the snippet'
do
first
(
:link
,
'Delete'
).
click
expect
(
page
).
not_to
have_content
(
snippet
.
title
)
end
end
spec/features/snippets/
edit
_snippet_spec.rb
→
spec/features/snippets/
user_edits
_snippet_spec.rb
View file @
9651521e
require
'rails_helper'
require
'rails_helper'
feature
'
Edit S
nippet'
,
:js
,
feature:
true
do
feature
'
User edits s
nippet'
,
:js
,
feature:
true
do
include
DropzoneHelper
include
DropzoneHelper
let
(
:file_name
)
{
'test.rb'
}
let
(
:file_name
)
{
'test.rb'
}
...
@@ -10,7 +10,7 @@ feature 'Edit Snippet', :js, feature: true do
...
@@ -10,7 +10,7 @@ feature 'Edit Snippet', :js, feature: true do
let
(
:snippet
)
{
create
(
:personal_snippet
,
:public
,
file_name:
file_name
,
content:
content
,
author:
user
)
}
let
(
:snippet
)
{
create
(
:personal_snippet
,
:public
,
file_name:
file_name
,
content:
content
,
author:
user
)
}
before
do
before
do
gitlab_
sign_in
(
user
)
sign_in
(
user
)
visit
edit_snippet_path
(
snippet
)
visit
edit_snippet_path
(
snippet
)
wait_for_requests
wait_for_requests
...
@@ -27,7 +27,7 @@ feature 'Edit Snippet', :js, feature: true do
...
@@ -27,7 +27,7 @@ feature 'Edit Snippet', :js, feature: true do
it
'updates the snippet with files attached'
do
it
'updates the snippet with files attached'
do
dropzone_file
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
dropzone_file
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
expect
(
page
.
find_field
(
"personal_snippet_description"
).
value
).
to
have_content
(
'banana_sample'
)
expect
(
page
.
find_field
(
'personal_snippet_description'
).
value
).
to
have_content
(
'banana_sample'
)
click_button
(
'Save changes'
)
click_button
(
'Save changes'
)
wait_for_requests
wait_for_requests
...
@@ -35,4 +35,24 @@ feature 'Edit Snippet', :js, feature: true do
...
@@ -35,4 +35,24 @@ feature 'Edit Snippet', :js, feature: true do
link
=
find
(
'a.no-attachment-icon img[alt="banana_sample"]'
)[
'src'
]
link
=
find
(
'a.no-attachment-icon img[alt="banana_sample"]'
)[
'src'
]
expect
(
link
).
to
match
(
%r{/uploads/personal_snippet/
#{
snippet
.
id
}
/
\h
{32}/banana_sample
\.
gif
\z
}
)
expect
(
link
).
to
match
(
%r{/uploads/personal_snippet/
#{
snippet
.
id
}
/
\h
{32}/banana_sample
\.
gif
\z
}
)
end
end
it
'updates the snippet to make it internal'
do
choose
'Internal'
click_button
'Save changes'
wait_for_requests
expect
(
page
).
to
have_no_xpath
(
"//i[@class='fa fa-lock']"
)
expect
(
page
).
to
have_xpath
(
"//i[@class='fa fa-shield']"
)
end
it
'updates the snippet to make it public'
do
choose
'Public'
click_button
'Save changes'
wait_for_requests
expect
(
page
).
to
have_no_xpath
(
"//i[@class='fa fa-lock']"
)
expect
(
page
).
to
have_xpath
(
"//i[@class='fa fa-globe']"
)
end
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