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
8f4c9e29
Commit
8f4c9e29
authored
Feb 21, 2018
by
Semyon Pupkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move project pages spinach tests to Rspec
https://gitlab.com/gitlab-org/gitlab-ce/issues/23036
parent
11bf575f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
202 additions
and
241 deletions
+202
-241
features/project/pages.feature
features/project/pages.feature
+0
-87
features/steps/project/pages.rb
features/steps/project/pages.rb
+0
-152
spec/features/projects/pages_spec.rb
spec/features/projects/pages_spec.rb
+202
-2
No files found.
features/project/pages.feature
deleted
100644 → 0
View file @
11bf575f
Feature
:
Project Pages
Background
:
Given
I sign in as a user
And
I own a project
Scenario
:
I
cannot navigate to Pages settings if pages enabled
Given
pages are disabled
And
I visit my project's settings page
Then
I should not see the
"Pages"
tab
Scenario
:
I
can navigate to Pages settings if pages enabled
Given
pages are enabled
And
I visit my project's settings page
Then
I should see the
"Pages"
tab
Scenario
:
I
can see the pages usage if not deployed
Given
pages are enabled
When
I visit the Project Pages
Then
I should see the usage of GitLab Pages
Scenario
:
I
can access the pages if deployed
Given
pages are enabled
And
pages are deployed
When
I visit the Project Pages
Then
I should be able to access the Pages
Scenario
:
I
should message that domains support is disabled
Given
pages are enabled
And
pages are deployed
And
support for external domains is disabled
When
I visit the Project Pages
Then
I should see that support for domains is disabled
Scenario
:
I
should see a new domain button
Given
pages are enabled
And
pages are exposed on external HTTP address
When
I visit the Project Pages
And
I should be able to add a New Domain
Scenario
:
I
should be able to add a new domain
Given
pages are enabled
And
pages are exposed on external HTTP address
When
I visit add a new Pages Domain
And
I fill the domain
And
I click on
"Create New Domain"
Then
I should see a new domain added
Scenario
:
I
should be able to add a new domain for project in group namespace
Given
I own a project in some group namespace
And
pages are enabled
And
pages are exposed on external HTTP address
When
I visit add a new Pages Domain
And
I fill the domain
And
I click on
"Create New Domain"
Then
I should see a new domain added
Scenario
:
I
should be denied to add the same domain twice
Given
pages are enabled
And
pages are exposed on external HTTP address
And
pages domain is added
When
I visit add a new Pages Domain
And
I fill the domain
And
I click on
"Create New Domain"
Then
I should see error message that domain already exists
Scenario
:
I
should message that certificates support is disabled when trying to add a new domain
Given
pages are enabled
And
pages are exposed on external HTTP address
And
pages domain is added
When
I visit add a new Pages Domain
Then
I should see that support for certificates is disabled
Scenario
:
I
should be able to add a new domain with certificate
Given
pages are enabled
And
pages are exposed on external HTTPS address
When
I visit add a new Pages Domain
And
I fill the domain
And
I fill the certificate and key
And
I click on
"Create New Domain"
Then
I should see a new domain added
Scenario
:
I
can remove the pages if deployed
Given
pages are enabled
And
pages are deployed
When
I visit the Project Pages
And
I click Remove Pages
Then
The Pages should get removed
features/steps/project/pages.rb
deleted
100644 → 0
View file @
11bf575f
class
Spinach::Features::ProjectPages
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedPaths
include
SharedProject
step
'pages are enabled'
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:host
).
and_return
(
'example.com'
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:port
).
and_return
(
80
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:https
).
and_return
(
false
)
end
step
'pages are disabled'
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
false
)
end
step
'I visit the Project Pages'
do
visit
project_pages_path
(
@project
)
end
step
'I should see the usage of GitLab Pages'
do
expect
(
page
).
to
have_content
(
'Configure pages'
)
end
step
'I should see the "Pages" tab'
do
page
.
within
'.nav-sidebar'
do
expect
(
page
).
to
have_link
(
'Pages'
)
end
end
step
'I should not see the "Pages" tab'
do
page
.
within
'.nav-sidebar'
do
expect
(
page
).
not_to
have_link
(
'Pages'
)
end
end
step
'pages are deployed'
do
pipeline
=
@project
.
pipelines
.
create
(
ref:
'HEAD'
,
sha:
@project
.
commit
(
'HEAD'
).
sha
,
source: :push
,
protected:
false
)
build
=
build
(
:ci_build
,
project:
@project
,
pipeline:
pipeline
,
ref:
'HEAD'
,
legacy_artifacts_file:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip'
),
legacy_artifacts_metadata:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip.meta'
)
)
result
=
::
Projects
::
UpdatePagesService
.
new
(
@project
,
build
).
execute
expect
(
result
[
:status
]).
to
eq
(
:success
)
end
step
'I should be able to access the Pages'
do
expect
(
page
).
to
have_content
(
'Access pages'
)
end
step
'I should see that support for domains is disabled'
do
expect
(
page
).
to
have_content
(
'Support for domains and certificates is disabled'
)
end
step
'support for external domains is disabled'
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_http
).
and_return
(
nil
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_https
).
and_return
(
nil
)
end
step
'pages are exposed on external HTTP address'
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_http
).
and_return
([
'1.1.1.1:80'
])
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_https
).
and_return
(
nil
)
end
step
'pages are exposed on external HTTPS address'
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_http
).
and_return
([
'1.1.1.1:80'
])
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_https
).
and_return
([
'1.1.1.1:443'
])
end
step
'I should be able to add a New Domain'
do
expect
(
page
).
to
have_content
(
'New Domain'
)
end
step
'I visit add a new Pages Domain'
do
visit
new_project_pages_domain_path
(
@project
)
end
step
'I fill the domain'
do
fill_in
'Domain'
,
with:
'my.test.domain.com'
end
step
'I click on "Create New Domain"'
do
click_button
'Create New Domain'
end
step
'I should see a new domain added'
do
expect
(
page
).
to
have_content
(
'Domains (1)'
)
expect
(
page
).
to
have_content
(
'my.test.domain.com'
)
end
step
'pages domain is added'
do
@project
.
pages_domains
.
create!
(
domain:
'my.test.domain.com'
)
end
step
'I should see error message that domain already exists'
do
expect
(
page
).
to
have_content
(
'Domain has already been taken'
)
end
step
'I should see that support for certificates is disabled'
do
expect
(
page
).
to
have_content
(
'Support for custom certificates is disabled'
)
end
step
'I fill the certificate and key'
do
fill_in
'Certificate (PEM)'
,
with:
'-----BEGIN CERTIFICATE-----
MIICGzCCAYSgAwIBAgIBATANBgkqhkiG9w0BAQUFADAbMRkwFwYDVQQDExB0ZXN0
LWNlcnRpZmljYXRlMB4XDTE2MDIxMjE0MzIwMFoXDTIwMDQxMjE0MzIwMFowGzEZ
MBcGA1UEAxMQdGVzdC1jZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
gYkCgYEApL4J9L0ZxFJ1hI1LPIflAlAGvm6ZEvoT4qKU5Xf2JgU7/2geNR1qlNFa
SvCc08Knupp5yTgmvyK/Xi09U0N82vvp4Zvr/diSc4A/RA6Mta6egLySNT438kdT
nY2tR5feoTLwQpX0t4IMlwGQGT5h6Of2fKmDxzuwuyffcIHqLdsCAwEAAaNvMG0w
DAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUxl9WSxBprB0z0ibJs3rXEk0+95AwCwYD
VR0PBAQDAgXgMBEGCWCGSAGG+EIBAQQEAwIGQDAeBglghkgBhvhCAQ0EERYPeGNh
IGNlcnRpZmljYXRlMA0GCSqGSIb3DQEBBQUAA4GBAGC4T8SlFHK0yPSa+idGLQFQ
joZp2JHYvNlTPkRJ/J4TcXxBTJmArcQgTIuNoBtC+0A/SwdK4MfTCUY4vNWNdese
5A4K65Nb7Oh1AdQieTBHNXXCdyFsva9/ScfQGEl7p55a52jOPs0StPd7g64uvjlg
YHi2yesCrOvVXt+lgPTd
-----END CERTIFICATE-----'
fill_in
'Key (PEM)'
,
with:
'-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKS+CfS9GcRSdYSN
SzyH5QJQBr5umRL6E+KilOV39iYFO/9oHjUdapTRWkrwnNPCp7qaeck4Jr8iv14t
PVNDfNr76eGb6/3YknOAP0QOjLWunoC8kjU+N/JHU52NrUeX3qEy8EKV9LeCDJcB
kBk+Yejn9nypg8c7sLsn33CB6i3bAgMBAAECgYA2D26w80T7WZvazYr86BNMePpd
j2mIAqx32KZHzt/lhh40J/SRtX9+Kl0Y7nBoRR5Ja9u/HkAIxNxLiUjwg9r6cpg/
uITEF5nMt7lAk391BuI+7VOZZGbJDsq2ulPd6lO+C8Kq/PI/e4kXcIjeH6KwQsuR
5vrXfBZ3sQfflaiN4QJBANBt8JY2LIGQF8o89qwUpRL5vbnKQ4IzZ5+TOl4RLR7O
AQpJ81tGuINghO7aunctb6rrcKJrxmEH1whzComybrMCQQDKV49nOBudRBAIgG4K
EnLzsRKISUHMZSJiYTYnablof8cKw1JaQduw7zgrUlLwnroSaAGX88+Jw1f5n2Lh
Vlg5AkBDdUGnrDLtYBCDEQYZHblrkc7ZAeCllDOWjxUV+uMqlCv8A4Ey6omvY57C
m6I8DkWVAQx8VPtozhvHjUw80rZHAkB55HWHAM3h13axKG0htCt7klhPsZHpx6MH
EPjGlXIT+aW2XiPmK3ZlCDcWIenE+lmtbOpI159Wpk8BGXs/s/xBAkEAlAY3ymgx
63BDJEwvOb2IaP8lDDxNsXx9XJNVvQbv5n15vNsLHbjslHfAhAbxnLQ1fLhUPqSi
nNp/xedE1YxutQ==
-----END PRIVATE KEY-----'
end
step
'I click Remove Pages'
do
click_link
'Remove pages'
end
step
'The Pages should get removed'
do
expect
(
@project
.
pages_deployed?
).
to
be_falsey
end
end
spec/features/projects/pages_spec.rb
View file @
8f4c9e29
...
...
@@ -17,6 +17,7 @@ feature 'Pages' do
scenario
'does not see anything to destroy'
do
visit
project_pages_path
(
project
)
expect
(
page
).
to
have_content
(
'Configure pages'
)
expect
(
page
).
not_to
have_link
(
'Remove pages'
)
expect
(
page
).
not_to
have_text
(
'Only the project owner can remove pages'
)
end
...
...
@@ -32,14 +33,163 @@ feature 'Pages' do
allow_any_instance_of
(
Project
).
to
receive
(
:pages_deployed?
)
{
true
}
end
scenario
'
sees "Remove pages" link
'
do
scenario
'
renders Access pages
'
do
visit
project_pages_path
(
project
)
expect
(
page
).
to
have_link
(
'Remove pages'
)
expect
(
page
).
to
have_content
(
'Access pages'
)
end
context
'when support for external domains is disabled'
do
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_http
).
and_return
(
nil
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_https
).
and_return
(
nil
)
end
it
'renders message that support is disabled'
do
visit
project_pages_path
(
project
)
expect
(
page
).
to
have_content
(
'Support for domains and certificates is disabled'
)
end
end
context
'when pages are exposed on external HTTP address'
do
shared_examples
'adds new domain'
do
it
'adds new domain'
do
visit
new_project_pages_domain_path
(
project
)
fill_in
'Domain'
,
with:
'my.test.domain.com'
click_button
'Create New Domain'
expect
(
page
).
to
have_content
(
'Domains (1)'
)
expect
(
page
).
to
have_content
(
'my.test.domain.com'
)
end
end
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_http
).
and_return
([
'1.1.1.1:80'
])
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_https
).
and_return
(
nil
)
end
it
'allows to add new domain'
do
visit
project_pages_path
(
project
)
expect
(
page
).
to
have_content
(
'New Domain'
)
end
it_behaves_like
'adds new domain'
context
'when project in group namespace'
do
it_behaves_like
'adds new domain'
do
let
(
:group
)
{
create
:group
}
let
(
:project
)
{
create
:project
,
namespace:
group
}
end
end
context
'when pages domain is added'
do
before
do
project
.
pages_domains
.
create!
(
domain:
'my.test.domain.com'
)
visit
new_project_pages_domain_path
(
project
)
end
it
'renders certificates is disabled'
do
expect
(
page
).
to
have_content
(
'Support for custom certificates is disabled'
)
end
it
'does not adds new domain and renders error message'
do
fill_in
'Domain'
,
with:
'my.test.domain.com'
click_button
'Create New Domain'
expect
(
page
).
to
have_content
(
'Domain has already been taken'
)
end
end
end
context
'when pages are exposed on external HTTPS address'
do
let
(
:certificate_pem
)
do
<<~
PEM
-----BEGIN CERTIFICATE-----
MIICGzCCAYSgAwIBAgIBATANBgkqhkiG9w0BAQUFADAbMRkwFwYDVQQDExB0ZXN0
LWNlcnRpZmljYXRlMB4XDTE2MDIxMjE0MzIwMFoXDTIwMDQxMjE0MzIwMFowGzEZ
MBcGA1UEAxMQdGVzdC1jZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
gYkCgYEApL4J9L0ZxFJ1hI1LPIflAlAGvm6ZEvoT4qKU5Xf2JgU7/2geNR1qlNFa
SvCc08Knupp5yTgmvyK/Xi09U0N82vvp4Zvr/diSc4A/RA6Mta6egLySNT438kdT
nY2tR5feoTLwQpX0t4IMlwGQGT5h6Of2fKmDxzuwuyffcIHqLdsCAwEAAaNvMG0w
DAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUxl9WSxBprB0z0ibJs3rXEk0+95AwCwYD
VR0PBAQDAgXgMBEGCWCGSAGG+EIBAQQEAwIGQDAeBglghkgBhvhCAQ0EERYPeGNh
IGNlcnRpZmljYXRlMA0GCSqGSIb3DQEBBQUAA4GBAGC4T8SlFHK0yPSa+idGLQFQ
joZp2JHYvNlTPkRJ/J4TcXxBTJmArcQgTIuNoBtC+0A/SwdK4MfTCUY4vNWNdese
5A4K65Nb7Oh1AdQieTBHNXXCdyFsva9/ScfQGEl7p55a52jOPs0StPd7g64uvjlg
YHi2yesCrOvVXt+lgPTd
-----END CERTIFICATE-----
PEM
end
let
(
:certificate_key
)
do
<<~
KEY
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKS+CfS9GcRSdYSN
SzyH5QJQBr5umRL6E+KilOV39iYFO/9oHjUdapTRWkrwnNPCp7qaeck4Jr8iv14t
PVNDfNr76eGb6/3YknOAP0QOjLWunoC8kjU+N/JHU52NrUeX3qEy8EKV9LeCDJcB
kBk+Yejn9nypg8c7sLsn33CB6i3bAgMBAAECgYA2D26w80T7WZvazYr86BNMePpd
j2mIAqx32KZHzt/lhh40J/SRtX9+Kl0Y7nBoRR5Ja9u/HkAIxNxLiUjwg9r6cpg/
uITEF5nMt7lAk391BuI+7VOZZGbJDsq2ulPd6lO+C8Kq/PI/e4kXcIjeH6KwQsuR
5vrXfBZ3sQfflaiN4QJBANBt8JY2LIGQF8o89qwUpRL5vbnKQ4IzZ5+TOl4RLR7O
AQpJ81tGuINghO7aunctb6rrcKJrxmEH1whzComybrMCQQDKV49nOBudRBAIgG4K
EnLzsRKISUHMZSJiYTYnablof8cKw1JaQduw7zgrUlLwnroSaAGX88+Jw1f5n2Lh
Vlg5AkBDdUGnrDLtYBCDEQYZHblrkc7ZAeCllDOWjxUV+uMqlCv8A4Ey6omvY57C
m6I8DkWVAQx8VPtozhvHjUw80rZHAkB55HWHAM3h13axKG0htCt7klhPsZHpx6MH
EPjGlXIT+aW2XiPmK3ZlCDcWIenE+lmtbOpI159Wpk8BGXs/s/xBAkEAlAY3ymgx
63BDJEwvOb2IaP8lDDxNsXx9XJNVvQbv5n15vNsLHbjslHfAhAbxnLQ1fLhUPqSi
nNp/xedE1YxutQ==
-----END PRIVATE KEY-----
KEY
end
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_http
).
and_return
([
'1.1.1.1:80'
])
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:external_https
).
and_return
([
'1.1.1.1:443'
])
end
it
'adds new domain with certificate'
do
visit
new_project_pages_domain_path
(
project
)
fill_in
'Domain'
,
with:
'my.test.domain.com'
fill_in
'Certificate (PEM)'
,
with:
certificate_pem
fill_in
'Key (PEM)'
,
with:
certificate_key
click_button
'Create New Domain'
expect
(
page
).
to
have_content
(
'Domains (1)'
)
expect
(
page
).
to
have_content
(
'my.test.domain.com'
)
end
end
end
it_behaves_like
'no pages deployed'
describe
'project settings page'
do
it
'renders "Pages" tab'
do
visit
edit_project_path
(
project
)
page
.
within
'.nav-sidebar'
do
expect
(
page
).
to
have_link
(
'Pages'
)
end
end
context
'when pages are disabled'
do
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
false
)
end
it
'does not render "Pages" tab'
do
visit
edit_project_path
(
project
)
page
.
within
'.nav-sidebar'
do
expect
(
page
).
not_to
have_link
(
'Pages'
)
end
end
end
end
end
context
'when the user is not the owner'
do
...
...
@@ -57,4 +207,54 @@ feature 'Pages' do
it_behaves_like
'no pages deployed'
end
describe
'Remove page'
do
context
'when user is the owner'
do
let
(
:project
)
{
create
:project
,
:repository
}
before
do
project
.
namespace
.
update
(
owner:
user
)
end
context
'when pages are deployed'
do
let
(
:pipeline
)
do
commit_sha
=
project
.
commit
(
'HEAD'
).
sha
project
.
pipelines
.
create
(
ref:
'HEAD'
,
sha:
commit_sha
,
source: :push
,
protected:
false
)
end
let
(
:ci_build
)
do
build
(
:ci_build
,
project:
project
,
pipeline:
pipeline
,
ref:
'HEAD'
,
legacy_artifacts_file:
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/pages.zip'
)),
legacy_artifacts_metadata:
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/pages.zip.meta'
))
)
end
before
do
result
=
Projects
::
UpdatePagesService
.
new
(
project
,
ci_build
).
execute
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
project
).
to
be_pages_deployed
end
it
'removes the pages'
do
visit
project_pages_path
(
project
)
expect
(
page
).
to
have_link
(
'Remove pages'
)
click_link
'Remove pages'
expect
(
project
.
pages_deployed?
).
to
be_falsey
end
end
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