Skip to content

Commit

Permalink
Merge pull request #17 from lofi-nowhale/noelle_model_creation
Browse files Browse the repository at this point in the history
feat: build model realtionships and validations for user, viewing par…
  • Loading branch information
JorjaF authored Oct 11, 2023
2 parents 4ef4b63 + 22886c0 commit 4397f73
Show file tree
Hide file tree
Showing 12 changed files with 624 additions and 231 deletions.
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

0 comments on commit 4397f73

Please sign in to comment.