Starting to get the tests in and working
This commit is contained in:
parent
dda03a1a9a
commit
d73d234465
@ -1,3 +1,6 @@
|
||||
class Caf < ApplicationRecord
|
||||
belongs_to :company
|
||||
|
||||
validates :name, presence: true
|
||||
validates :name, uniqueness: { scope: :company_id, message: "should be unique to the company"}
|
||||
end
|
||||
|
||||
20
test/fixtures/cafs.yml
vendored
20
test/fixtures/cafs.yml
vendored
@ -1,11 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
#
|
||||
# one:
|
||||
# company: one
|
||||
# name: MyString1
|
||||
# description: MyText1
|
||||
#
|
||||
# two:
|
||||
# company: two
|
||||
# name: MyString2
|
||||
# description: MyText2
|
||||
|
||||
one:
|
||||
company: one
|
||||
name: HiddenAgendaCAF
|
||||
description: MyText1
|
||||
|
||||
two:
|
||||
company: two
|
||||
name: CaudleMotorsportCAF
|
||||
description: MyText2
|
||||
|
||||
10
test/fixtures/companies.yml
vendored
10
test/fixtures/companies.yml
vendored
@ -1,7 +1,7 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# one:
|
||||
# name: HiddenAgendaLtd
|
||||
#
|
||||
# two:
|
||||
# name: CaudleMotorsports
|
||||
one:
|
||||
name: HiddenAgendaLtd
|
||||
|
||||
two:
|
||||
name: CaudleMotorsports
|
||||
|
||||
Binary file not shown.
@ -1,7 +1,14 @@
|
||||
require "test_helper"
|
||||
|
||||
class CafTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
test "name_unique_per_company" do
|
||||
company = Company.where(name: "HiddenAgendaLtd").first
|
||||
c = company.cafs.new(name: "HiddenAgendaCAF")
|
||||
assert !c.save
|
||||
end
|
||||
|
||||
test "name cant be blank" do
|
||||
c = Caf.new
|
||||
assert !c.save
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user