Commit 48417893 authored by Alex Braha Stoll's avatar Alex Braha Stoll

Remove directories as one of the attributes of WikiDirectory

parent b0ad4e0e
class WikiDirectory
include ActiveModel::Validations
attr_accessor :slug, :pages, :directories
attr_accessor :slug, :pages
validates :slug, presence: true
def initialize(slug, pages = [], directories = [])
def initialize(slug, pages = [])
@slug = slug
@pages = pages
@directories = directories
end
# Relative path to the partial to be used when rendering collections
......
......@@ -8,10 +8,9 @@ RSpec.describe WikiDirectory, models: true do
end
describe '#initialize' do
context 'when there are pages and directories' do
context 'when there are pages' do
let(:pages) { [build(:wiki_page)] }
let(:other_directories) { [build(:wiki_directory)] }
let(:directory) { WikiDirectory.new('/path_up_to/dir', pages, other_directories) }
let(:directory) { WikiDirectory.new('/path_up_to/dir', pages) }
it 'sets the slug attribute' do
expect(directory.slug).to eq('/path_up_to/dir')
......@@ -20,13 +19,9 @@ RSpec.describe WikiDirectory, models: true do
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
context 'when there are no pages' do
let(:directory) { WikiDirectory.new('/path_up_to/dir') }
it 'sets the slug attribute' do
......@@ -36,10 +31,6 @@ RSpec.describe WikiDirectory, models: true do
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment