Starting to get the tests in and working

This commit is contained in:
Jez Caudle 2023-01-26 19:48:25 +00:00
parent dda03a1a9a
commit d73d234465
5 changed files with 28 additions and 18 deletions

View File

@ -1,3 +1,6 @@
class Caf < ApplicationRecord class Caf < ApplicationRecord
belongs_to :company belongs_to :company
validates :name, presence: true
validates :name, uniqueness: { scope: :company_id, message: "should be unique to the company"}
end end

View File

@ -1,11 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
#
# one: one:
# company: one company: one
# name: MyString1 name: HiddenAgendaCAF
# description: MyText1 description: MyText1
#
# two: two:
# company: two company: two
# name: MyString2 name: CaudleMotorsportCAF
# description: MyText2 description: MyText2

View File

@ -1,7 +1,7 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# one: one:
# name: HiddenAgendaLtd name: HiddenAgendaLtd
#
# two: two:
# name: CaudleMotorsports name: CaudleMotorsports

Binary file not shown.

View File

@ -1,7 +1,14 @@
require "test_helper" require "test_helper"
class CafTest < ActiveSupport::TestCase class CafTest < ActiveSupport::TestCase
# test "the truth" do test "name_unique_per_company" do
# assert true company = Company.where(name: "HiddenAgendaLtd").first
# end c = company.cafs.new(name: "HiddenAgendaCAF")
assert !c.save
end
test "name cant be blank" do
c = Caf.new
assert !c.save
end
end end