Sha256: d91ae74e5415e22a21e6d8218acf8d6772831bce71f9f8e6f582e1761017f098
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require 'test_helper' class Project include Mongoid::Document acts_as_sluggable field :name, :type => String end class Organization include Mongoid::Document acts_as_sluggable :generate_from => :alternative_name, :store_as => :alternative_slug field :alternative_name, :type => String field :alternative_slug, :type => String end class TestActsAsSluggable < Test::Unit::TestCase def setup ::Mongoid.configure do |config| name = "acts_as_sluggable_test" host = "localhost" config.master = Mongo::Connection.new.db(name) config.logger = nil end end context "default parameters" do setup do @project = Project.create(:name => 'Some name') end should "create a slug" do assert_equal('some-name', @project.slug) end context :to_param do should "return the slug too" do assert_equal('some-name', @project.to_param) end end end context "custom parameters" do setup do @organization = Organization.create(:alternative_name => 'Some Other Name') end should "create a slug using the custom field and store it on the custom slug field" do assert_equal('some-other-name', @organization.alternative_slug) end context :to_param do should "return the slug too" do assert_equal('some-other-name', @organization.to_param) end end end def teardown ::Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_sluggable-0.0.1 | test/unit/test_as_sluggable.rb |