Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RSpec] comment, news, currency type model #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions app/models/user_bet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ class UserBet < ApplicationRecord
belongs_to :user
belongs_to :bet

has_many :teams, dependent: :nullify

scope :newest, ->{order created_at: :desc}
scope :load_result_bet, ->(result){where result_bet: result}

Expand All @@ -19,10 +17,8 @@ class UserBet < ApplicationRecord
numericality: {greater_than_or_equal_to: 0}

def self.search start_month, end_month
if start_month && end_month
UserBet.load_by_date start_month, end_month
else
UserBet.load_by_today
end
return unless start_month && end_month

UserBet.load_by_date start_month, end_month
end
end
7 changes: 7 additions & 0 deletions spec/model/comment_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "rails_helper"
RSpec.describe Comment, type: :model do
describe "Associations" do
it {should belong_to(:user)}
it {should belong_to(:news)}
end
end
6 changes: 6 additions & 0 deletions spec/model/currency_type_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require "rails_helper"
RSpec.describe CurrencyType, type: :model do
describe "Associations" do
it {should have_many(:currencies).dependent(:nullify)}
end
end
6 changes: 6 additions & 0 deletions spec/model/news_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require "rails_helper"
RSpec.describe News, type: :model do
describe "Associations" do
it {should belong_to(:user)}
end
end