Sha256: 7aa117cebce26e9127b68df892b20f81ab29c8c4d98d4a4f56e1973cd215fffe

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

require 'test_helper'

class RepresenterTest < ActionController::TestCase
  include Roar::Rails::TestCase

  tests SingersController

  test "representers can use URL helpers" do
    get :show, :id => "bumi"
    assert_body "{\"name\":\"Bumi\",\"links\":[{\"rel\":\"self\",\"href\":\"http://roar.apotomo.de/singers/Bumi\"}]}"
  end

  test "it works with uninitialized config.representer.default_url_options" do
    url_options = Rails.application.config.representer.default_url_options

    begin
      Rails.application.config.representer.default_url_options = nil
      assert_raises RuntimeError, ArgumentError do
        get :show, :id => "bumi"
      end
      assert $!.message =~ /Missing host to link to/
    rescue
    ensure
      Rails.application.config.representer.default_url_options = url_options
    end
  end
end


class DecoratorTest < ActionController::TestCase
  include Roar::Rails::TestCase

  tests BandsController

  test "it renders URLs using the decorator" do
    get :show, :id => 1, :format => :json
    assert_body "{\"name\":\"Bodyjar\",\"links\":[{\"rel\":\"self\",\"href\":\"http://roar.apotomo.de/bands/Bodyjar\"}]}"
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/roar-rails-1.2.0/test/representer_test.rb
roar-rails-1.2.0 test/representer_test.rb
roar-rails-1.1.0 test/representer_test.rb
roar-rails-1.0.2 test/representer_test.rb
roar-rails-1.0.1 test/representer_test.rb
roar-rails-1.0.0 test/representer_test.rb
roar-rails-0.1.6 test/representer_test.rb
roar-rails-0.1.5 test/representer_test.rb
roar-rails-0.1.4 test/representer_test.rb
roar-rails-0.1.3 test/representer_test.rb
roar-rails-0.1.2 test/representer_test.rb
roar-rails-0.1.1 test/representer_test.rb
roar-rails-0.1.0 test/representer_test.rb
roar-rails-0.0.15 test/representer_test.rb