Sha256: 731136df63902ab141dba15386abf3a686884d8d29ffd32e3ebec47223b68e90

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

require "test_helper"
require "govuk_content_models/test_helpers/local_services"

class LocalTransactionEditionTest < ActiveSupport::TestCase
  include LocalServicesHelper
  BINS = 1
  HOUSING_BENEFIT = 2
  NONEXISTENT = 999

  def setup
    @artefact = FactoryGirl.create(:artefact)
  end

  test "should be a transaction search format" do
    bins_transaction = LocalTransactionEdition.new(
      lgsl_code:     BINS,
      title:         "Transaction",
      slug:          "slug",
      panopticon_id: @artefact.id
    )
    assert_equal "transaction", bins_transaction.search_format
  end


  test "should validate on save that a LocalService exists for that lgsl_code" do
    s = LocalService.create!(lgsl_code: BINS, providing_tier: %w{county unitary})

    lt = LocalTransactionEdition.new(lgsl_code: NONEXISTENT, title: "Foo", slug: "foo", panopticon_id: @artefact.id)
    lt.save
    assert !lt.valid?

    lt = LocalTransactionEdition.new(lgsl_code: s.lgsl_code, title: "Bar", slug: "bar", panopticon_id: @artefact.id)
    lt.save
    assert lt.valid?
    assert lt.persisted?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
govuk_content_models-42.0.0 test/models/local_transaction_edition_test.rb
govuk_content_models-41.1.1 test/models/local_transaction_edition_test.rb
govuk_content_models-41.1.0 test/models/local_transaction_edition_test.rb
govuk_content_models-41.0.0 test/models/local_transaction_edition_test.rb
govuk_content_models-40.0.0 test/models/local_transaction_edition_test.rb
govuk_content_models-39.0.0 test/models/local_transaction_edition_test.rb