2019-04-28 21:10:54 +03:00
|
|
|
require "rails_helper"
|
2015-04-17 02:13:10 +03:00
|
|
|
|
|
|
|
describe Event, type: :model do
|
|
|
|
let(:event) { build :event }
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "is invalid if the event agrement is not accepted" do
|
2015-04-17 02:13:10 +03:00
|
|
|
event.agreement = false
|
|
|
|
expect(event).to have_error_on :agreement
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "is invalid without a title" do
|
|
|
|
event.title = ""
|
2015-04-17 02:13:10 +03:00
|
|
|
expect(event).to have_error_on :title
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
describe "length" do
|
|
|
|
it "must be present" do
|
|
|
|
event.length = ""
|
2015-04-17 02:13:10 +03:00
|
|
|
expect(event).to have_error_on :length
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "must be a number" do
|
|
|
|
event.length = "foo"
|
2015-04-17 02:13:10 +03:00
|
|
|
expect(event).to have_error_on :length
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "must be larger than zero" do
|
|
|
|
event.length = "-10"
|
2015-04-17 02:13:10 +03:00
|
|
|
expect(event).to have_error_on :length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "is invalid without an abstract" do
|
|
|
|
event.abstract = ""
|
2015-04-17 02:13:10 +03:00
|
|
|
expect(event).to have_error_on :abstract
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "is invalid without a description" do
|
|
|
|
event.description = ""
|
2015-04-17 02:13:10 +03:00
|
|
|
expect(event).to have_error_on :description
|
|
|
|
end
|
|
|
|
end
|