2019-04-28 21:10:54 +03:00
|
|
|
require "rails_helper"
|
2014-08-10 20:30:37 +03:00
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
RSpec.describe Track, type: :model do
|
|
|
|
it "is invalid without a name" do
|
|
|
|
expect(build(:track, name: "")).to have_error_on :name
|
2014-08-10 20:30:37 +03:00
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
describe "color" do
|
|
|
|
it "must be present" do
|
|
|
|
expect(build(:track, color: "")).to have_error_on :color
|
2014-08-10 20:30:37 +03:00
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "must be a hex RGB triplet" do
|
|
|
|
expect(build(:track, color: "foobar")).to have_error_on :color
|
|
|
|
expect(build(:track, color: "000000")).to_not have_error_on :color
|
|
|
|
expect(build(:track, color: "#000000")).to_not have_error_on :color
|
2014-08-10 20:30:37 +03:00
|
|
|
end
|
|
|
|
end
|
2014-11-05 11:45:04 +02:00
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "belongs to a conference" do
|
2014-11-05 11:45:04 +02:00
|
|
|
conference = create :conference
|
|
|
|
expect(build(:track, conference_id: conference.id).conference).to eq conference
|
|
|
|
end
|
2014-08-10 20:30:37 +03:00
|
|
|
end
|