This repository has been archived by the owner on Jan 1, 2018. It is now read-only.
-
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
7 changed files
with
63 additions
and
2 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
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,7 @@ | ||
class League < ApplicationRecord | ||
belongs_to :club | ||
|
||
validates :name, presence: true, uniqueness: { scope: :club_id } | ||
validates :slug, presence: true | ||
validates :club_id, presence: true | ||
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateLeague < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :leagues do |t| | ||
t.string :name | ||
t.string :slug | ||
t.references :club, foreign_key: true | ||
t.boolean :privated, default: true | ||
|
||
t.timestamps null: false | ||
end | ||
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,15 @@ | ||
FactoryBot.define do | ||
factory :league do | ||
sequence :name { |n| "League Number #{n}" } | ||
sequence :slug { |n| "league-number-#{n}" } | ||
club | ||
|
||
trait :private do | ||
privated true | ||
end | ||
|
||
trait :not_private do | ||
privated false | ||
end | ||
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,15 @@ | ||
require 'rails_helper' | ||
|
||
describe League, type: :model do | ||
context 'relationships' do | ||
it { should belong_to :club } | ||
end | ||
|
||
context 'validations' do | ||
it { should validate_presence_of :name } | ||
it { should validate_uniqueness_of(:name).scoped_to(:club_id) } | ||
it { should validate_presence_of :slug } | ||
it { should validate_presence_of :club_id } | ||
end | ||
context 'methods' | ||
end |