debian-mirror-gitlab/spec/models/wiki_directory_spec.rb

45 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
RSpec.describe WikiDirectory do
2017-08-17 22:00:37 +05:30
describe 'validations' do
subject { build(:wiki_directory) }
it { is_expected.to validate_presence_of(:slug) }
end
describe '#initialize' do
context 'when there are pages' do
let(:pages) { [build(:wiki_page)] }
2017-09-10 17:25:29 +05:30
let(:directory) { described_class.new('/path_up_to/dir', pages) }
2017-08-17 22:00:37 +05:30
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
end
context 'when there are no pages' do
2017-09-10 17:25:29 +05:30
let(:directory) { described_class.new('/path_up_to/dir') }
2017-08-17 22:00:37 +05:30
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
end
end
describe '#to_partial_path' do
it 'returns the relative path to the partial to be used' do
directory = build(:wiki_directory)
expect(directory.to_partial_path).to eq('projects/wikis/wiki_directory')
end
end
end