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

feat: build model realtionships and validations for user, viewing par… #17

Merged
merged 1 commit into from
Oct 11, 2023
Merged
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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ group :test do
gem 'launchy'
gem 'rspec-rails'
gem 'simplecov'
gem 'shoulda-matchers'
end


3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ GEM
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
shoulda-matchers (5.3.0)
activesupport (>= 5.2.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -282,6 +284,7 @@ DEPENDENCIES
rails (~> 7.0.4, >= 7.0.4.2)
rspec-rails
rubocop-rails
shoulda-matchers
simplecov
sprockets-rails
stimulus-rails
Expand Down
6 changes: 6 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
class User < ApplicationRecord
validates_presence_of :name, :email
validates :email, uniqueness: { case_sensitive: false }

has_many :user_viewing_parties
has_many :viewing_parties, through: :user_viewing_parties

end
4 changes: 4 additions & 0 deletions app/models/user_viewing_party.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class UserViewingParty < ApplicationRecord
belongs_to :user
belongs_to :viewing_party
end
7 changes: 7 additions & 0 deletions app/models/viewing_party.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ViewingParty < ApplicationRecord
validates_presence_of :movie_title, :movie_image, :start_time
validates_numericality_of :movie_id, :duration

has_many :user_viewing_parties
has_many :users, through: :user_viewing_parties
end
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"result": {
"line": 93.44
"line": 100.0
}
}
48 changes: 38 additions & 10 deletions coverage/.resultset.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@
"/Users/noellehemphill/turing_work/3mod/projects/viewing_party_lite_7/app/models/user.rb": {
"lines": [
1,
1,
1,
null,
1,
1,
null,
null
]
},
Expand All @@ -280,37 +286,59 @@
null
]
},
"/Users/noellehemphill/turing_work/3mod/projects/viewing_party_lite_7/app/controllers/users_controller.rb": {
"/Users/noellehemphill/turing_work/3mod/projects/viewing_party_lite_7/spec/models/user_viewing_party_spec.rb": {
"lines": [
1,
null,
1,
1,
2,
2,
null,
null,
null
]
},
"/Users/noellehemphill/turing_work/3mod/projects/viewing_party_lite_7/app/models/user_viewing_party.rb": {
"lines": [
1,
1,
1,
null
]
},
"/Users/noellehemphill/turing_work/3mod/projects/viewing_party_lite_7/spec/models/viewing_party_spec.rb": {
"lines": [
1,
null,
1,
1,
2,
2,
2,
2,
2,
null,
null,
1,
0,
0,
0,
null,
0,
2,
2,
null,
null,
null
]
},
"/Users/noellehemphill/turing_work/3mod/projects/viewing_party_lite_7/app/controllers/application_controller.rb": {
"/Users/noellehemphill/turing_work/3mod/projects/viewing_party_lite_7/app/models/viewing_party.rb": {
"lines": [
1,
1,
1,
null,
null,
1,
1,
null
]
}
},
"timestamp": 1697039978
"timestamp": 1697042045
}
}
Loading