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
48417893
Commit
48417893
authored
Dec 31, 2016
by
Alex Braha Stoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove directories as one of the attributes of WikiDirectory
parent
b0ad4e0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
15 deletions
+5
-15
app/models/wiki_directory.rb
app/models/wiki_directory.rb
+2
-3
spec/models/wiki_directory_spec.rb
spec/models/wiki_directory_spec.rb
+3
-12
No files found.
app/models/wiki_directory.rb
View file @
48417893
class
WikiDirectory
class
WikiDirectory
include
ActiveModel
::
Validations
include
ActiveModel
::
Validations
attr_accessor
:slug
,
:pages
,
:directories
attr_accessor
:slug
,
:pages
validates
:slug
,
presence:
true
validates
:slug
,
presence:
true
def
initialize
(
slug
,
pages
=
[]
,
directories
=
[]
)
def
initialize
(
slug
,
pages
=
[])
@slug
=
slug
@slug
=
slug
@pages
=
pages
@pages
=
pages
@directories
=
directories
end
end
# Relative path to the partial to be used when rendering collections
# Relative path to the partial to be used when rendering collections
...
...
spec/models/wiki_directory_spec.rb
View file @
48417893
...
@@ -8,10 +8,9 @@ RSpec.describe WikiDirectory, models: true do
...
@@ -8,10 +8,9 @@ RSpec.describe WikiDirectory, models: true do
end
end
describe
'#initialize'
do
describe
'#initialize'
do
context
'when there are pages
and directories
'
do
context
'when there are pages'
do
let
(
:pages
)
{
[
build
(
:wiki_page
)]
}
let
(
:pages
)
{
[
build
(
:wiki_page
)]
}
let
(
:other_directories
)
{
[
build
(
:wiki_directory
)]
}
let
(
:directory
)
{
WikiDirectory
.
new
(
'/path_up_to/dir'
,
pages
)
}
let
(
:directory
)
{
WikiDirectory
.
new
(
'/path_up_to/dir'
,
pages
,
other_directories
)
}
it
'sets the slug attribute'
do
it
'sets the slug attribute'
do
expect
(
directory
.
slug
).
to
eq
(
'/path_up_to/dir'
)
expect
(
directory
.
slug
).
to
eq
(
'/path_up_to/dir'
)
...
@@ -20,13 +19,9 @@ RSpec.describe WikiDirectory, models: true do
...
@@ -20,13 +19,9 @@ RSpec.describe WikiDirectory, models: true do
it
'sets the pages attribute'
do
it
'sets the pages attribute'
do
expect
(
directory
.
pages
).
to
eq
(
pages
)
expect
(
directory
.
pages
).
to
eq
(
pages
)
end
end
it
'sets the directories attribute'
do
expect
(
directory
.
directories
).
to
eq
(
other_directories
)
end
end
end
context
'when there are no pages
or directories
'
do
context
'when there are no pages'
do
let
(
:directory
)
{
WikiDirectory
.
new
(
'/path_up_to/dir'
)
}
let
(
:directory
)
{
WikiDirectory
.
new
(
'/path_up_to/dir'
)
}
it
'sets the slug attribute'
do
it
'sets the slug attribute'
do
...
@@ -36,10 +31,6 @@ RSpec.describe WikiDirectory, models: true do
...
@@ -36,10 +31,6 @@ RSpec.describe WikiDirectory, models: true do
it
'sets the pages attribute to an empty array'
do
it
'sets the pages attribute to an empty array'
do
expect
(
directory
.
pages
).
to
eq
([])
expect
(
directory
.
pages
).
to
eq
([])
end
end
it
'sets the directories attribute to an empty array'
do
expect
(
directory
.
directories
).
to
eq
([])
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