Sha256: bc1d9b47599c198134f46ca5553c8d7e1868aacbaaac99639911033b3cb8e62b

Contents?: true

Size: 1.39 KB

Versions: 16

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe ::ActiveRemote::Integration do
  let(:guid) { "GUID-derp" }
  subject { Tag.new(:guid => guid) }

  context "#to_param" do
    # API
    specify { subject.should respond_to(:to_param) }

    it "returns the guid if the guid is present (by default)" do
      subject.to_param.should eq(guid)
    end
  end

  context "#cache_key" do
    # API
    specify { subject.should respond_to(:cache_key) }

    it "sets 'new' as the identifier when the record has not been persisted" do
      subject.should_receive(:new_record?).and_return(true)
      subject.cache_key.should match(/tag\/new/)
    end

    it "sets the cache_key to the class/guid as a default" do
      subject.should_receive(:new_record?).and_return(false)
      subject.cache_key.should eq("tag/#{guid}")
    end

    it "adds the 'updated_at' attribute to the cache_key if updated_at is present" do
      ::ActiveRemote.config.default_cache_key_updated_at = true
      twenty_o_one_one = subject[:updated_at] = DateTime.new(2001, 01, 01)
      subject.should_receive(:new_record?).and_return(false)
      subject.cache_key.should eq("tag/#{guid}-#{twenty_o_one_one.to_s(:number)}")
      subject[:updated_at] = nil
      ::ActiveRemote.config.default_cache_key_updated_at = false
    end

    it "defaults the cache updated_at to false" do
      ::ActiveRemote.config.default_cache_key_updated_at?.should be_false
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
active_remote-2.1.1 spec/lib/active_remote/integration_spec.rb
active_remote-2.1.0 spec/lib/active_remote/integration_spec.rb
active_remote-2.1.0.rc2 spec/lib/active_remote/integration_spec.rb
active_remote-2.1.0.rc1 spec/lib/active_remote/integration_spec.rb
active_remote-2.1.0.beta2 spec/lib/active_remote/integration_spec.rb
active_remote-2.1.0.beta1 spec/lib/active_remote/integration_spec.rb
active_remote-2.0.2 spec/lib/active_remote/integration_spec.rb
active_remote-2.0.1 spec/lib/active_remote/integration_spec.rb
active_remote-2.0.0 spec/lib/active_remote/integration_spec.rb
active_remote-2.0.0.rc2 spec/lib/active_remote/integration_spec.rb
active_remote-2.0.0.rc1 spec/lib/active_remote/integration_spec.rb
active_remote-1.8.1 spec/lib/active_remote/integration_spec.rb
active_remote-1.8.0 spec/lib/active_remote/integration_spec.rb
active_remote-1.8.0.rc1 spec/lib/active_remote/integration_spec.rb
active_remote-1.7.1 spec/lib/active_remote/integration_spec.rb
active_remote-1.7.0 spec/lib/active_remote/integration_spec.rb