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 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
......
...@@ -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
......
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