Sha256: f35930193a3b6d94266dfa1e2bc328fc9a88ae47e849484f7d2d63ed9b7781b1

Contents?: true

Size: 1.89 KB

Versions: 1

Compression:

Stored size: 1.89 KB

Contents

require './spec/spec_helper'

describe Photo do
  before(:each) do
    @photo = Photo.new({
      "ResourceUri" => "/listings/20100815153524571646000000/photos/20101124153422574618000000",
      "Id"          => "20101124153422574618000000",
      "Name"        => "Photo 1 name",
      "Caption"     => "caption here",
      "UriThumb"    => "http://photos.cdn.flexmls.com/xyz-t.jpg",
      "Uri300"      => "http://photos.cdn.flexmls.com/xyz.jpg",
      "Uri640"      => "http://cdn.resize.flexmls.com/az/640x480/true/20101124153422574618000000-o.jpg",
      "Uri800"      => "http://cdn.resize.flexmls.com/az/800x600/true/20101124153422574618000000-o.jpg",
      "Uri1024"     => "http://cdn.resize.flexmls.com/az/1024x768/true/20101124153422574618000000-o.jpg",
      "Uri1280"     => "http://cdn.resize.flexmls.com/az/1280x1024/true/20101124153422574618000000-o.jpg",
      "UriLarge"    => "http://photos.cdn.flexmls.com/xyz-o.jpg",
      "Primary"     => true
    })

  end


  it "responds to" do
    @photo.should respond_to(:primary?)
    Photo.should respond_to(:find_by_listing_key)
  end

  it "knows if it's the primary photo" do
    @photo.primary?.should be_true
    @photo.Primary = false
    @photo.primary?.should be_false
  end

  describe "find photos by listing id"  do
    before do
      stub_auth_request
      stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/listings/1234/photos").
                   with(:query => {
                     :ApiSig => "d060aa12d3ef573aff7298302e0237fa", 
                     :AuthToken => "c401736bf3d3f754f07c04e460e09573",
                     :ApiUser => "foobar"
                   }).
                   to_return(:body => fixture('listing_photos_index.json'))
    end

    it "should get an array of photos" do
      p = Photo.find_by_listing_key('1234')
      p.should be_an(Array)
    end

  end


  after(:each) do  
    @photo = nil
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flexmls_api-0.4.5 spec/unit/flexmls_api/models/photo_spec.rb