-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
169 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Nodes | ||
class Calendar | ||
include Neo4j::ActiveNode | ||
|
||
property :service_id, type: Integer | ||
property :monday, type: Integer | ||
property :tuesday, type: Integer | ||
property :wednesday, type: Integer | ||
property :thursday, type: Integer | ||
property :friday, type: Integer | ||
property :saturday, type: Integer | ||
property :sunday, type: Integer | ||
property :start_date, type: String | ||
property :end_date, type: String | ||
|
||
property :created_at | ||
property :updated_at | ||
|
||
validates :service_id, presence: true | ||
validates :monday, presence: true, inclusion: { in: 0..1} | ||
validates :tuesday, presence: true, inclusion: { in: 0..1} | ||
validates :wednesday, presence: true, inclusion: { in: 0..1} | ||
validates :thursday, presence: true, inclusion: { in: 0..1} | ||
validates :friday, presence: true, inclusion: { in: 0..1} | ||
validates :saturday, presence: true, inclusion: { in: 0..1} | ||
validates :sunday, presence: true, inclusion: { in: 0..1} | ||
validates :start_date, presence: true, length: { is: 8 } | ||
validates :end_date, presence: true, length: { is: 8 } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"result": { | ||
"covered_percent": 98.83 | ||
"covered_percent": 98.97 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
db/neo4j/migrate/20170112012126_force_create_nodes_calendar_uuid_constraint.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ForceCreateNodesCalendarUuidConstraint < Neo4j::Migrations::Base | ||
def up | ||
add_constraint :"Nodes::Calendar", :uuid, force: true | ||
end | ||
|
||
def down | ||
drop_constraint :"Nodes::Calendar", :uuid | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'rails_helper' | ||
|
||
describe Nodes::Calendar do | ||
describe '.create' do | ||
it 'persists a user with valid attributes' do | ||
calendar = Nodes::Calendar.create( | ||
service_id: 20, | ||
monday: 0, | ||
tuesday: 1, | ||
wednesday: 0, | ||
thursday: 1, | ||
friday: 1, | ||
saturday: 0, | ||
sunday: 1, | ||
start_date: '20170101', | ||
end_date: '20171208' | ||
) | ||
|
||
expect(calendar).to be_persisted | ||
end | ||
|
||
it 'does not persist if attributes are not valid' do | ||
calendar = Nodes::Calendar.create( | ||
service_id: 20, | ||
monday: 0, | ||
tuesday: 1, | ||
wednesday: 0, | ||
saturday: 9, | ||
sunday: 1, | ||
start_date: '20170101', | ||
end_date: '20171208754' | ||
) | ||
|
||
expect(calendar).not_to be_persisted | ||
expect(calendar.errors.messages).to eq( | ||
thursday: ["can't be blank", "is not included in the list"], | ||
friday: ["can't be blank", "is not included in the list"], | ||
saturday: ["is not included in the list"], | ||
end_date: ["is the wrong length (should be 8 characters)"] | ||
) | ||
end | ||
end | ||
end |