Sha256: 2028301e547dc83590244ad10f4ba6b869b2102ffc5c64d68db408f87aa3c88b
Contents?: true
Size: 1.57 KB
Versions: 7
Compression:
Stored size: 1.57 KB
Contents
require 'spec_helper' describe Outpost::Model::Naming do describe "::to_title" do it "returns the titleized class name" do Person.to_title.should eq "Person" Person.stub(:name) { "SomeModule::Person" } Person.to_title.should eq "Person" Person.stub(:name) { "SomeModule::PersonThing"} Person.to_title.should eq "Person Thing" end end #---------------- describe "#title_method" do pending end #---------------- describe "#to_title" do it "uses one of the specified title attributes if available" do Outpost.config.title_attributes = [:name] person = create :person, name: "Bryan Ricker" person.to_title.should eq "Bryan Ricker" end # This is actually being handled by config.title_attributes being injected # with :simple_title... we can test it here anyways it "falls back to a simple_title if none of the attributes match" do Outpost.config.title_attributes = [:title] person = create :person person.should_receive(:simple_title).and_return("Simple Title") person.to_title.should eq "Simple Title" end end #---------------- describe "#simple_title" do it "returns a simple name for a new object" do person = build :person person.new_record?.should be_true person.simple_title.should eq "New Person" end it "returns a simple name for a persisted object" do person = create :person person.id.should be_present person.new_record?.should be_false person.simple_title.should eq "Person ##{person.id}" end end end
Version data entries
7 entries across 7 versions & 1 rubygems