Sha256: 4f232c6805b08311cc532238d60ddd4e783cbcfd5d992f080e4740b7116971a1

Contents?: true

Size: 1.3 KB

Versions: 9

Compression:

Stored size: 1.3 KB

Contents

require "test_helper"

class ResourcesControllerIndexTest < ActionController::TestCase
  tests Fogged::ResourcesController
  include ResourceTestHelper

  def setup
    super
    @movie = movies(:movie_one)
  end

  test "should index all resources for movies" do
    get :index, :type => "movie"

    assert_json_resources(Movie.all.map(&:resources).flatten)
  end

  test "should index resources for a movie" do
    get :index, :type => "movie", :type_id => @movie.id

    assert_json_resources(@movie.resources.to_a)
  end

  test "should index resources for movies" do
    resources = movies(:movie_one, :movie_two).map(&:resources).flatten
    get :index,
        :type => "movie",
        :type_ids => movies(:movie_one, :movie_two).map(&:id)

    assert_json_resources(resources)
  end

  test "should index resources for a movie with search query on name" do
    res = Fogged::Resource.create(
      :name => "footest barish",
      :extension => "txt",
      :content_type => "text/plain"
    )
    @movie.resources << res

    get :index,
        :type => "movie",
        :type_id => @movie.id,
        :query => "test"

    assert_json_resources([res])
  end

  test "should index resources with invalid movie id" do
    get :index, :type => "movie", :type_id => 1234567890

    assert_json_resources([])
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fogged-0.0.13 test/dummy/test/controllers/resources_controller/index_test.rb
fogged-0.0.12 test/dummy/test/controllers/resources_controller/index_test.rb
fogged-0.0.11 test/dummy/test/controllers/resources_controller/index_test.rb
fogged-0.0.10 test/dummy/test/controllers/resources_controller/index_test.rb
fogged-0.0.9 test/dummy/test/controllers/resources_controller/index_test.rb
fogged-0.0.8 test/dummy/test/controllers/resources_controller/index_test.rb
fogged-0.0.7 test/dummy/test/controllers/resources_controller/index_test.rb
fogged-0.0.6 test/dummy/test/controllers/resources_controller/index_test.rb
fogged-0.0.5 test/dummy/test/controllers/resources_controller/index_test.rb