Skip to content

Commit

Permalink
Added specs for slugs on dashes and underscore-type situations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Sep 7, 2016
1 parent 8fd4ea0 commit 05fe040
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-09-07 14:58:20 -0400 using RuboCop version 0.34.2.
# on 2016-09-07 16:18:43 -0400 using RuboCop version 0.34.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -27,7 +27,7 @@ Metrics/MethodLength:
# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 939
Max: 947

# Offense count: 3
Metrics/PerceivedComplexity:
Expand Down
14 changes: 12 additions & 2 deletions spec/mongoid/slug_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Mongoid
Book.create(title: 'A Thousand Plateaus')
end

context 'should not persist incorrect slugs' do
it 'slugs should not be generated from invalid documents' do
context 'special cases' do
it 'slugs are not be generated from invalid documents' do
# this will fail now
x = IncorrectSlugPersistence.create!(name: 'test')
expect(x.slug).to eq('test')
Expand All @@ -28,6 +28,16 @@ module Mongoid
expect(book.reload.slugs).to eq ['book']
end

it 'defaults slugs for dashes' do
book = Book.create!(title: '-')
expect(book.reload.slugs).to eq ['book']
end

it 'defaults slugs for underscores' do
book = Book.create!(title: '_')
expect(book.reload.slugs).to eq ['book']
end

it 'defaults slugs for nil strings' do
book = Book.create!
expect(book.reload.slugs).to eq ['book']
Expand Down

0 comments on commit 05fe040

Please sign in to comment.