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
Tatuya Kamada
gitlab-ce
Commits
f8afe47a
Commit
f8afe47a
authored
Jul 21, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Service.external_wikis return only active external wikis
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
8ed97054
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
29 deletions
+52
-29
app/models/service.rb
app/models/service.rb
+1
-1
db/migrate/20160721081015_nullify_has_external_wiki_in_projects.rb
...e/20160721081015_nullify_has_external_wiki_in_projects.rb
+13
-0
db/schema.rb
db/schema.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+37
-27
No files found.
app/models/service.rb
View file @
f8afe47a
...
@@ -26,7 +26,7 @@ class Service < ActiveRecord::Base
...
@@ -26,7 +26,7 @@ class Service < ActiveRecord::Base
scope
:visible
,
->
{
where
.
not
(
type:
[
'GitlabIssueTrackerService'
,
'GitlabCiService'
])
}
scope
:visible
,
->
{
where
.
not
(
type:
[
'GitlabIssueTrackerService'
,
'GitlabCiService'
])
}
scope
:issue_trackers
,
->
{
where
(
category:
'issue_tracker'
)
}
scope
:issue_trackers
,
->
{
where
(
category:
'issue_tracker'
)
}
scope
:external_wikis
,
->
{
where
(
type:
'ExternalWikiService'
)
}
scope
:external_wikis
,
->
{
where
(
type:
'ExternalWikiService'
)
.
active
}
scope
:active
,
->
{
where
(
active:
true
)
}
scope
:active
,
->
{
where
(
active:
true
)
}
scope
:without_defaults
,
->
{
where
(
default:
false
)
}
scope
:without_defaults
,
->
{
where
(
default:
false
)
}
...
...
db/migrate/20160721081015_nullify_has_external_wiki_in_projects.rb
0 → 100644
View file @
f8afe47a
class
NullifyHasExternalWikiInProjects
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
def
up
execute
(
"UPDATE projects SET has_external_wiki = NULL"
)
end
def
down
end
end
db/schema.rb
View file @
f8afe47a
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201607
18153603
)
do
ActiveRecord
::
Schema
.
define
(
version:
201607
21081015
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
...
spec/models/project_spec.rb
View file @
f8afe47a
...
@@ -458,44 +458,54 @@ describe Project, models: true do
...
@@ -458,44 +458,54 @@ describe Project, models: true do
end
end
end
end
describe
"#cache_has_external_wiki"
do
describe
'#external_wiki'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
it
"stores true if there is an external wiki"
do
context
'with an active external wiki'
do
services
=
double
(
:service
,
external_wikis:
[
ExternalWikiService
.
new
])
before
do
expect
(
project
).
to
receive
(
:services
).
and_return
(
services
)
create
(
:service
,
project:
project
,
type:
'ExternalWikiService'
,
active:
true
)
project
.
external_wiki
end
expect
do
it
'sets :has_external_wiki as true'
do
project
.
cache_has_external_wiki
expect
(
project
.
has_external_wiki
).
to
be
(
true
)
end
.
to
change
{
project
.
has_external_wiki
}.
to
(
true
)
end
end
it
"stores false if there is no external wiki"
do
it
'sets :has_external_wiki as false if an external wiki service is destroyed later'
do
services
=
double
(
:service
,
external_wikis:
[])
expect
(
project
.
has_external_wiki
).
to
be
(
true
)
expect
(
project
).
to
receive
(
:services
).
and_return
(
services
)
expect
do
project
.
services
.
external_wikis
.
first
.
destroy
project
.
cache_has_external_wiki
end
.
to
change
{
project
.
has_external_wiki
}.
to
(
false
)
expect
(
project
.
has_external_wiki
).
to
be
(
false
)
end
end
end
it
"changes to true if an external wiki service is created later"
do
context
'with an inactive external wiki'
do
expect
do
before
do
project
.
cache_has_external_wiki
create
(
:service
,
project:
project
,
type:
'ExternalWikiService'
,
active:
false
)
end
.
to
change
{
project
.
has_external_wiki
}.
to
(
false
)
end
expect
do
it
'sets :has_external_wiki as false'
do
create
(
:service
,
type:
"ExternalWikiService"
,
project:
project
)
expect
(
project
.
has_external_wiki
).
to
be
(
false
)
end
.
to
change
{
project
.
has_external_wiki
}.
to
(
true
)
end
end
end
it
"changes to false if an external wiki service is destroyed later"
do
context
'with no external wiki'
do
service
=
create
(
:service
,
type:
"ExternalWikiService"
,
project:
project
)
before
do
expect
(
project
.
has_external_wiki
).
to
be_truthy
project
.
external_wiki
end
expect
do
it
'sets :has_external_wiki as false'
do
service
.
destroy
expect
(
project
.
has_external_wiki
).
to
be
(
false
)
end
.
to
change
{
project
.
has_external_wiki
}.
to
(
false
)
end
it
'sets :has_external_wiki as true if an external wiki service is created later'
do
expect
(
project
.
has_external_wiki
).
to
be
(
false
)
create
(
:service
,
project:
project
,
type:
'ExternalWikiService'
,
active:
true
)
expect
(
project
.
has_external_wiki
).
to
be
(
true
)
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