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
06d96a9a
Commit
06d96a9a
authored
Feb 19, 2016
by
Kamil Trzcinski
Committed by
James Edwards-Jones
Jan 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce pages_deployed? to Project model
parent
8a861c87
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
17 deletions
+30
-17
app/models/project.rb
app/models/project.rb
+4
-2
app/views/projects/pages/_access.html.haml
app/views/projects/pages/_access.html.haml
+1
-1
app/views/projects/pages/_destroy.haml
app/views/projects/pages/_destroy.haml
+1
-1
app/views/projects/pages/_use.html.haml
app/views/projects/pages/_use.html.haml
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+17
-6
spec/services/projects/update_pages_service_spec.rb
spec/services/projects/update_pages_service_spec.rb
+6
-6
No files found.
app/models/project.rb
View file @
06d96a9a
...
...
@@ -1164,9 +1164,11 @@ class Project < ActiveRecord::Base
ensure_runners_token!
end
def
pages_url
return
unless
Dir
.
exist?
(
public_pages_path
)
def
pages_deployed?
Dir
.
exist?
(
public_pages_path
)
end
def
pages_url
# The hostname always needs to be in downcased
# All web servers convert hostname to lowercase
host
=
"
#{
namespace
.
path
}
.
#{
Settings
.
pages
.
host
}
"
.
downcase
...
...
app/views/projects/pages/_access.html.haml
View file @
06d96a9a
-
if
@project
.
pages_
url
-
if
@project
.
pages_
deployed?
.panel.panel-default
.panel-heading
Access pages
...
...
app/views/projects/pages/_destroy.haml
View file @
06d96a9a
-
if
can?
(
current_user
,
:remove_pages
,
@project
)
&&
@project
.
pages_
url
-
if
can?
(
current_user
,
:remove_pages
,
@project
)
&&
@project
.
pages_
deployed?
.panel.panel-default.panel.panel-danger
.panel-heading
Remove pages
.errors-holder
...
...
app/views/projects/pages/_use.html.haml
View file @
06d96a9a
-
unless
@project
.
pages_
url
-
unless
@project
.
pages_
deployed?
.panel.panel-info
.panel-heading
Configure pages
...
...
spec/models/project_spec.rb
View file @
06d96a9a
...
...
@@ -1068,6 +1068,23 @@ describe Project, models: true do
end
end
describe
'#pages_deployed?'
do
let
(
:project
)
{
create
:empty_project
}
subject
{
project
.
pages_deployed?
}
context
'if public folder does exist'
do
before
{
FileUtils
.
mkdir_p
(
project
.
public_pages_path
)
}
after
{
FileUtils
.
rmdir
(
project
.
public_pages_path
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
"if public folder doesn't exist"
do
it
{
is_expected
.
to
be_falsey
}
end
end
describe
'.search'
do
let
(
:project
)
{
create
(
:empty_project
,
description:
'kitten mittens'
)
}
...
...
@@ -1854,16 +1871,10 @@ describe Project, models: true do
subject
{
project
.
pages_url
}
before
do
FileUtils
.
mkdir_p
(
project
.
public_pages_path
)
allow
(
Settings
.
pages
).
to
receive
(
:host
).
and_return
(
domain
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:url
).
and_return
(
'http://example.com'
)
end
after
do
FileUtils
.
rmdir
(
project
.
public_pages_path
)
end
context
'group page'
do
let
(
:group_name
)
{
'Group'
}
let
(
:project_name
)
{
'group.example.com'
}
...
...
spec/services/projects/update_pages_service_spec.rb
View file @
06d96a9a
...
...
@@ -27,9 +27,9 @@ describe Projects::UpdatePagesService do
end
it
'succeeds'
do
expect
(
project
.
pages_
url
).
to
be_nil
expect
(
project
.
pages_
deployed?
).
to
be_falsey
expect
(
execute
).
to
eq
(
:success
)
expect
(
project
.
pages_
url
).
to_not
be_nil
expect
(
project
.
pages_
deployed?
).
to
be_truthy
end
it
'limits pages size'
do
...
...
@@ -39,11 +39,11 @@ describe Projects::UpdatePagesService do
it
'removes pages after destroy'
do
expect
(
PagesWorker
).
to
receive
(
:perform_in
)
expect
(
project
.
pages_
url
).
to
be_nil
expect
(
project
.
pages_
deployed?
).
to
be_falsey
expect
(
execute
).
to
eq
(
:success
)
expect
(
project
.
pages_
url
).
to_not
be_nil
expect
(
project
.
pages_
deployed?
).
to
be_truthy
project
.
destroy
expect
(
Dir
.
exist?
(
project
.
public_pages_path
)
).
to
be_falsey
expect
(
project
.
pages_deployed?
).
to
be_falsey
end
it
'fails if sha on branch is not latest'
do
...
...
@@ -61,7 +61,7 @@ describe Projects::UpdatePagesService do
it
'fails to remove project pages when no pages is deployed'
do
expect
(
PagesWorker
).
to_not
receive
(
:perform_in
)
expect
(
project
.
pages_
url
).
to
be_nil
expect
(
project
.
pages_
deployed?
).
to
be_falsey
project
.
destroy
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