Sha256: ae6675185d18b51a8dca77872e94e52575fe15e624adf3fb45747d66e83bdddc

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 KB

Contents

require_relative '../test_helper'
require_relative '../resource_test'

module MeducationSDK
  class ExternalResourceTest < ResourceTest

    test_resource(ExternalResource, '/external_resources')

    def test_created_by_calls_sdk
      er = ExternalResource.new(created_by_id: 3)
      MeducationSDK::User.expects(:find).with(3)
      er.created_by
    end

    def test_indexable_content_calls_sdk
      er = ExternalResource.new(id: 5)
      content = "Foobar123"
      MeducationSDK::IndexableContent.expects(:where).with(item_id: er.id, item_type: "ExternalResource").returns([IndexableContent.new(content: content)])
      assert_equal content, er.indexable_content
    end

    def test_indexable_content_deals_with_no_result
      er = ExternalResource.new(id: 5)
      MeducationSDK::IndexableContent.expects(:where).with(item_id: er.id, item_type: "ExternalResource").returns([])
      assert_equal "", er.indexable_content
    end

    def test_responds_to_rating
      er = ExternalResource.new(rating: 5)
      assert er.respond_to?(:rating)
    end

    def test_can_retrigger_metadata_load
      Loquor.expects(:post).with('/external_resources/12/reimport_metadata', {})
      ExternalResource.reimport_metadata(12)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
meducation_sdk-2.2.0 test/resources/external_resource_test.rb
meducation_sdk-2.1.4 test/resources/external_resource_test.rb
meducation_sdk-2.1.3 test/resources/external_resource_test.rb
meducation_sdk-2.1.2 test/resources/external_resource_test.rb
meducation_sdk-2.1.1 test/resources/external_resource_test.rb
meducation_sdk-2.1.0 test/resources/external_resource_test.rb
meducation_sdk-2.0.5 test/resources/external_resource_test.rb
meducation_sdk-2.0.4 test/resources/external_resource_test.rb
meducation_sdk-2.0.3 test/resources/external_resource_test.rb