require 'rails_helper'

RSpec.describe NonWorkflowProject, type: :model do
  describe "#identifier" do
    it "gets set on initialization as uuid" do
      record = create :non_workflow_project
      record.identifier.should be_present
      record.identifier.size.should eq 36
      match = record.identifier.match(HasUuidIdentifier::UUID_MATCH)
      match[1].should eq '1'
      match[:version].should eq '1'
    end

    it "can be found by its uuid (and also still its id)" do
      record = create :non_workflow_project
      uuid_queried_record = described_class.find(record.identifier)
      uuid_queried_record.should eq record

      id_queried_record = described_class.find(record.id)
      id_queried_record.should eq record
    end
  end
end
