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
Jérome Perrin
gitlab-ce
Commits
b361a67f
Commit
b361a67f
authored
Dec 26, 2016
by
Alex Braha Stoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add model WikiDirectory
parent
8d8c5d9f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
app/models/wiki_directory.rb
app/models/wiki_directory.rb
+13
-0
spec/factories/wiki_directories.rb
spec/factories/wiki_directories.rb
+6
-0
spec/models/wiki_directory_spec.rb
spec/models/wiki_directory_spec.rb
+45
-0
No files found.
app/models/wiki_directory.rb
0 → 100644
View file @
b361a67f
class
WikiDirectory
include
ActiveModel
::
Validations
attr_accessor
:slug
,
:pages
,
:directories
validates
:slug
,
presence:
true
def
initialize
(
slug
,
pages
=
[],
directories
=
[])
@slug
=
slug
@pages
=
pages
@directories
=
directories
end
end
spec/factories/wiki_directories.rb
0 → 100644
View file @
b361a67f
FactoryGirl
.
define
do
factory
:wiki_directory
do
slug
'/path_up_to/dir'
initialize_with
{
new
(
slug
)
}
end
end
spec/models/wiki_directory_spec.rb
0 → 100644
View file @
b361a67f
require
'spec_helper'
RSpec
.
describe
WikiDirectory
,
models:
true
do
describe
'validations'
do
subject
{
build
(
:wiki_directory
)
}
it
{
is_expected
.
to
validate_presence_of
(
:slug
)
}
end
describe
'#initialize'
do
context
'when there are pages and directories'
do
let
(
:pages
)
{
[
build
(
:wiki_page
)]
}
let
(
:other_directories
)
{
[
build
(
:wiki_directory
)]
}
let
(
:directory
)
{
WikiDirectory
.
new
(
'/path_up_to/dir'
,
pages
,
other_directories
)
}
it
'sets the slug attribute'
do
expect
(
directory
.
slug
).
to
eq
(
'/path_up_to/dir'
)
end
it
'sets the pages attribute'
do
expect
(
directory
.
pages
).
to
eq
(
pages
)
end
it
'sets the directories attribute'
do
expect
(
directory
.
directories
).
to
eq
(
other_directories
)
end
end
context
'when there are no pages or directories'
do
let
(
:directory
)
{
WikiDirectory
.
new
(
'/path_up_to/dir'
)
}
it
'sets the slug attribute'
do
expect
(
directory
.
slug
).
to
eq
(
'/path_up_to/dir'
)
end
it
'sets the pages attribute to an empty array'
do
expect
(
directory
.
pages
).
to
eq
([])
end
it
'sets the directories attribute to an empty array'
do
expect
(
directory
.
directories
).
to
eq
([])
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