Remove directories as one of the attributes of WikiDirectory

This commit is contained in:
Alex Braha Stoll 2016-12-31 17:27:03 -02:00
parent b0ad4e0e87
commit 48417893d7
2 changed files with 5 additions and 15 deletions

View file

@ -1,14 +1,13 @@
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

View file

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