Sha256: 81fc573e802ca1b8118b76a6675f9dca64f769572ce25ba3f244811ccacacd73

Contents?: true

Size: 1.99 KB

Versions: 33

Compression:

Stored size: 1.99 KB

Contents

# encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Sharing" do
  include Rack::Test::Methods

  def app
    @@app
  end

  before(:each) do
    @params = {
      :url    => 'http://example.com/test',
      :key    => 'asdfasdf',
      :target => 'facebook'
    }
  end

  [:post, :get].each do |verb|
    describe "facebook via #{verb.to_s.upcase}" do
      it "should create a shortened URL" do
        lambda {
          self.send verb, '/api/share', @params
        }.should change(Firefly::Url, :count).by(1)
      end

      it "should redirect to facebook with status" do
        self.send verb, '/api/share', @params
        last_response.should be_redirect
        last_response['Location'].should match(/facebook.com/i)
      end

      it "should post the short url to facebook" do
        self.send verb, '/api/share', @params
        url = Firefly::Url.first(:url => @params[:url])

        last_response['Location'].should include(URI.escape("http://test.host/#{url.code}"))
      end

      it "should not allow sharing of example.org URL" do
        self.send verb, '/api/share', @params.merge(:url => 'http://example.org/test123')
        last_response.status.should eql(401)
        last_response.body.should match(/cannot share that URL/i)
      end

      it "should not create a short URL for example.org URL" do
        lambda {
          self.send verb, '/api/share', @params.merge(:url => 'http://example.org/test123')
        }.should_not change(Firefly::Url, :count)
      end

      it "should not share to unknown target" do
        self.send verb, '/api/share', @params.merge(:target => 'twitterbook')
        last_response.status.should eql(401)
        last_response.body.should match(/cannot share that URL/i)
      end

      it "should not create a short URL for unknown target" do
        lambda {
          self.send verb, '/api/share', @params.merge(:target => 'twitterbook')
        }.should_not change(Firefly::Url, :count)
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
tmin-0.2.6 spec/firefly/sharing_facebook_spec.rb
tmin-0.2.5 spec/firefly/sharing_facebook_spec.rb
tmin-0.2.4 spec/firefly/sharing_facebook_spec.rb
tmin-0.2.3 spec/firefly/sharing_facebook_spec.rb
tmin-0.2.2 spec/firefly/sharing_facebook_spec.rb
tmin-0.2.1 spec/firefly/sharing_facebook_spec.rb
tmin-0.2.0 spec/firefly/sharing_facebook_spec.rb
tmin-0.1.9 spec/firefly/sharing_facebook_spec.rb
tmin-0.1.8 spec/firefly/sharing_facebook_spec.rb
tmin-0.1.7 spec/firefly/sharing_facebook_spec.rb
tmin-0.1.6 spec/firefly/sharing_facebook_spec.rb
tmin_test-0.0.5 spec/firefly/sharing_facebook_spec.rb
tmin_test-0.0.4 spec/firefly/sharing_facebook_spec.rb
tmin_test-0.0.3 spec/firefly/sharing_facebook_spec.rb
tmin_test-0.0.2 spec/firefly/sharing_facebook_spec.rb
tmin_test-0.0.1 spec/firefly/sharing_facebook_spec.rb
tmin-0.1.5 spec/firefly/sharing_facebook_spec.rb
tmin-0.1.4 spec/firefly/sharing_facebook_spec.rb
tmin-0.1.3 spec/firefly/sharing_facebook_spec.rb
tmin-0.1.2 spec/firefly/sharing_facebook_spec.rb