Skip to content

Commit

Permalink
accepting upstream PR namick#56
Browse files Browse the repository at this point in the history
https://github.com/namick/obfuscate_id/pull/56/files

Merge remote-tracking branch 'mattvanhorn/fix-unsaved-behavior'
  • Loading branch information
gilesbowkett committed Feb 15, 2018
2 parents 3cf19d7 + 8246e3b commit 9c7477f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/obfuscate_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def obfuscate_id_default_spin

module InstanceMethods
def to_param
ObfuscateId.hide(self.id, self.class.obfuscate_id_spin)
ObfuscateId.hide(self.id, self.class.obfuscate_id_spin) if self.id
end

# Override ActiveRecord::Persistence#reload
Expand Down
3 changes: 1 addition & 2 deletions spec/dummy/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'obfuscate_id', '~> 0.2.0'
gem 'obfuscate_id', path: '../../'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
Expand All @@ -44,4 +44,3 @@ group :development, :test do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end

8 changes: 8 additions & 0 deletions spec/models/post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@
should eq([post1, post2])
end
end

context 'When not persisted yet' do
let (:new_post) { Post.new content: "one" }

it 'has no param' do
expect(new_post.to_param).to be_nil
end
end
end

0 comments on commit 9c7477f

Please sign in to comment.