Starting to get the tests in and working
This commit is contained in:
parent
dda03a1a9a
commit
d73d234465
@ -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
|
||||||
|
|||||||
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
|
# 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
|
||||||
|
|||||||
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
|
# 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.
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user