Sha256: 3112bf9d01b5b2679f9cc865c2777baa6099b7ed15fbf0718949d8a7c04fb3ea

Contents?: true

Size: 1.11 KB

Versions: 76

Compression:

Stored size: 1.11 KB

Contents

require "test_helper"

class CuratedListTest < ActiveSupport::TestCase
  test "should validate format of slug" do
    cl = CuratedList.new(slug: 'I am not a valid slug')
    assert !cl.valid?
    assert cl.errors[:slug].any?, "Doesn't have error on slug"
  end

  test "should include ability to have a section tag" do
    cl = FactoryGirl.create(:curated_list)
    tag = FactoryGirl.create(:live_tag, tag_id: 'batman', title: 'Batman', tag_type: 'section')

    cl.sections = ['batman']
    cl.save

    assert_equal [tag], cl.sections
  end

  test "should return artefacts in relationship order, not their natural order" do
    a = FactoryGirl.create(:artefact, name: "A")
    b = FactoryGirl.create(:artefact, name: "B")
    cl = FactoryGirl.create(:curated_list, artefact_ids: [b._id, a._id])
    assert_equal ["B", "A"], cl.artefacts.map(&:name)
  end

  test "should translate string IDs to BSON::ObjectIds for artefacts set via artefact_ids" do
    a = FactoryGirl.create(:artefact, name: "A")
    cl = FactoryGirl.create(:curated_list, artefact_ids: [a.id.to_s])
    assert cl.artefact_ids.first.is_a?(BSON::ObjectId)
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
govuk_content_models-41.1.1 test/models/curated_list_test.rb
govuk_content_models-41.1.0 test/models/curated_list_test.rb
govuk_content_models-41.0.0 test/models/curated_list_test.rb
govuk_content_models-40.0.0 test/models/curated_list_test.rb
govuk_content_models-39.0.0 test/models/curated_list_test.rb
govuk_content_models-38.0.0 test/models/curated_list_test.rb
govuk_content_models-37.0.0 test/models/curated_list_test.rb
govuk_content_models-36.0.0 test/models/curated_list_test.rb
govuk_content_models-35.0.1 test/models/curated_list_test.rb
govuk_content_models-35.0.0 test/models/curated_list_test.rb
govuk_content_models-34.0.0 test/models/curated_list_test.rb
govuk_content_models-33.0.0 test/models/curated_list_test.rb
govuk_content_models-32.3.1 test/models/curated_list_test.rb
govuk_content_models-32.3.0 test/models/curated_list_test.rb
govuk_content_models-32.2.0 test/models/curated_list_test.rb
govuk_content_models-32.1.0 test/models/curated_list_test.rb
govuk_content_models-32.0.0 test/models/curated_list_test.rb
govuk_content_models-31.4.0 test/models/curated_list_test.rb
govuk_content_models-31.3.0 test/models/curated_list_test.rb
govuk_content_models-31.2.2 test/models/curated_list_test.rb