Skip to content

Commit

Permalink
Merge branch 'master' into add-planner-new-release-badge
Browse files Browse the repository at this point in the history
  • Loading branch information
notable-sebastian committed Feb 13, 2025
2 parents 3d73d39 + 3edceae commit aa55f7b
Show file tree
Hide file tree
Showing 43 changed files with 2,830 additions and 2,516 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,9 @@ jobs:
name: system_test_screenshots
path: ./tmp/screenshots
retention-days: 2

- uses: joshmfrankel/simplecov-check-action@main
if: github.actor != 'dependabot[bot]'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
minimum_suite_coverage: 40
7 changes: 7 additions & 0 deletions .github/workflows/scraper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ jobs:
else
echo "There were no changes. Nothing to do."
fi
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: scraper_screenshot
path: ./tmp/capybara
retention-days: 5
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@
/public/packs-test

tags

# Ignore coverage reports
/coverage
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ gem "omniauth", "~> 2.1"
gem "omniauth-google-oauth2", '~> 1.2'
gem "omniauth-rails_csrf_protection", '~> 1.0'
gem 'pg', '~> 1.5'
gem 'puma', '~> 6.5'
gem 'puma', '~> 6.6'
gem 'rollbar', '~> 3.6'
gem 'sassc-rails', '~> 2.1.2'
gem 'stimulus-rails', '~> 1.3'
Expand All @@ -30,7 +30,7 @@ end

group :development do
gem "letter_opener", "~> 1.10"
gem 'rubocop', '~> 1.70'
gem 'rubocop', '~> 1.71'
gem 'rubocop-performance', '~> 1.23', require: false
gem 'rubocop-rails', '~> 2.29', require: false
gem 'web-console', '~> 4.2'
Expand All @@ -40,4 +40,5 @@ group :test do
gem 'capybara', '~> 3.40'
gem 'selenium-webdriver', '~> 4.28'
gem 'shoulda-matchers', '~> 6.0'
gem 'simplecov', require: false
end
72 changes: 43 additions & 29 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,16 @@ GEM
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
crass (1.0.6)
date (3.4.0)
date (3.4.1)
devise (4.9.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.5.1)
dotenv (3.1.6)
docile (1.4.1)
dotenv (3.1.7)
drb (2.2.1)
ed25519 (1.3.0)
erubi (1.13.1)
Expand All @@ -134,13 +135,14 @@ GEM
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.8.0)
irb (1.14.3)
irb (1.15.1)
pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.9.1)
json (2.10.1)
jwt (2.10.1)
base64
kamal (2.4.0)
kamal (2.5.2)
activesupport (>= 7.0)
base64 (~> 0.2)
bcrypt_pbkdf (~> 1.0)
Expand All @@ -151,14 +153,14 @@ GEM
sshkit (>= 1.23.0, < 2.0)
thor (~> 1.3)
zeitwerk (>= 2.6.18, < 3.0)
language_server-protocol (3.17.0.3)
language_server-protocol (3.17.0.4)
launchy (3.0.0)
addressable (~> 2.8)
childprocess (~> 5.0)
letter_opener (1.10.0)
launchy (>= 2.2, < 4)
logger (1.6.5)
loofah (2.23.1)
loofah (2.24.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand All @@ -176,22 +178,22 @@ GEM
bigdecimal (~> 3.1)
net-http (0.6.0)
uri
net-imap (0.5.1)
net-imap (0.5.6)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-scp (4.0.0)
net-scp (4.1.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-smtp (0.5.0)
net-protocol
net-ssh (7.3.0)
nio4r (2.7.4)
nokogiri (1.17.2)
nokogiri (1.18.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oauth2 (2.0.9)
Expand Down Expand Up @@ -219,25 +221,29 @@ GEM
orm_adapter (0.5.0)
ostruct (0.6.1)
parallel (1.26.3)
parser (3.3.7.0)
parser (3.3.7.1)
ast (~> 2.4.1)
racc
pg (1.5.9)
psych (5.2.2)
pp (0.6.2)
prettyprint
prettyprint (0.2.0)
psych (5.2.3)
date
stringio
public_suffix (5.0.4)
puma (6.5.0)
puma (6.6.0)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.1.8)
rack (3.1.10)
rack-protection (4.1.1)
base64 (>= 0.1.0)
logger (>= 1.6.0)
rack (>= 3.0.0, < 4)
rack-session (2.0.0)
rack-session (2.1.0)
base64 (>= 0.1.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack-test (2.2.0)
rack (>= 1.3)
rackup (2.2.1)
rack (>= 3)
Expand Down Expand Up @@ -272,7 +278,7 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rdoc (6.10.0)
rdoc (6.12.0)
psych (>= 4.0.0)
regexp_parser (2.10.0)
reline (0.6.0)
Expand All @@ -281,40 +287,40 @@ GEM
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.4.0)
rollbar (3.6.0)
rspec-core (3.13.2)
rollbar (3.6.1)
rspec-core (3.13.3)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (7.1.0)
rspec-rails (7.1.1)
actionpack (>= 7.0)
activesupport (>= 7.0)
railties (>= 7.0)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.70.0)
rspec-support (3.13.2)
rubocop (1.71.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.36.2, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.37.0)
rubocop-ast (1.38.0)
parser (>= 3.3.1.0)
rubocop-performance (1.23.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.29.0)
rubocop-rails (2.29.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
Expand All @@ -338,6 +344,12 @@ GEM
websocket (~> 1.0)
shoulda-matchers (6.4.0)
activesupport (>= 5.2.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
Expand All @@ -348,8 +360,9 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkit (1.23.2)
sshkit (1.24.0)
base64
logger
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
Expand All @@ -359,7 +372,7 @@ GEM
stringio (3.1.2)
thor (1.3.2)
tilt (2.0.10)
timeout (0.4.2)
timeout (0.4.3)
turbo-rails (2.0.11)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
Expand Down Expand Up @@ -403,16 +416,17 @@ DEPENDENCIES
omniauth-google-oauth2 (~> 1.2)
omniauth-rails_csrf_protection (~> 1.0)
pg (~> 1.5)
puma (~> 6.5)
puma (~> 6.6)
rails (~> 8.0.0)
rollbar (~> 3.6)
rspec-rails (~> 7.1)
rubocop (~> 1.70)
rubocop (~> 1.71)
rubocop-performance (~> 1.23)
rubocop-rails (~> 2.29)
sassc-rails (~> 2.1.2)
selenium-webdriver (~> 4.28)
shoulda-matchers (~> 6.0)
simplecov
stimulus-rails (~> 1.3)
turbo-rails (~> 2.0)
web-console (~> 4.2)
Expand Down
29 changes: 29 additions & 0 deletions app/assets/stylesheets/_rating.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.rating-container {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
gap: 12px;
}

.average-rating {
display: flex;
align-items: center;
margin-left: 4px;
gap: 4px;
}

.rating-items {
display: flex;
align-items: center;
flex-direction: row-reverse;
}

.interactive-star {
transition: transform 0.25s ease;

&:hover,
&:hover ~ .interactive-star {
transform: scale(1.3);
}
}
23 changes: 23 additions & 0 deletions app/controllers/reviews_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class ReviewsController < ApplicationController
before_action :authenticate_user!
before_action :set_review, only: [:destroy]

def create
@review = current_user.reviews.find_or_initialize_by(subject_id: params[:subject_id])
@review.update!(rating: params[:rating])

redirect_to subject_path(@review.subject)
end

def destroy
@review.destroy!

redirect_to subject_path(@review.subject)
end

private

def set_review
@review = current_user.reviews.find(params[:id])
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class PlannedSubjectsController < ApplicationController
class SubjectPlansController < ApplicationController
before_action :authenticate_user!
before_action :ensure_feature_enabled!

Expand All @@ -7,16 +7,16 @@ def index
end

def create
current_user.planned_subjects.create!(subject_id: params[:subject_id])
current_user.subject_plans.create!(subject_id: params[:subject_id])

redirect_to planned_subjects_path
redirect_to subject_plans_path
end

def destroy
planned_subject = current_user.planned_subjects.find_by!(subject_id: params[:subject_id])
planned_subject.destroy!
subject_plan = current_user.subject_plans.find_by!(subject_id: params[:subject_id])
subject_plan.destroy!

redirect_to planned_subjects_path
redirect_to subject_plans_path
end

private
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/subjects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def index
end

def show
@user_review = current_user.reviews.find_by(subject:) if current_user

respond_to do |format|
format.html { subject }
end
Expand Down
7 changes: 7 additions & 0 deletions app/models/review.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Review < ApplicationRecord
belongs_to :user
belongs_to :subject

validates :user_id, uniqueness: { scope: :subject_id, message: "You can only review a subject once." }
validates :rating, presence: true, inclusion: { in: 1..5 }
end
5 changes: 5 additions & 0 deletions app/models/subject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Subject < ApplicationRecord
has_one :course, -> { where is_exam: false }, class_name: 'Approvable', dependent: :destroy, inverse_of: :subject
has_one :exam, -> { where is_exam: true }, class_name: 'Approvable', dependent: :destroy, inverse_of: :subject
belongs_to :group, class_name: 'SubjectGroup', optional: true
has_many :reviews, dependent: :destroy

validates :name, presence: true
validates :credits, presence: true
Expand Down Expand Up @@ -47,5 +48,9 @@ def hidden_by_default?
revalid? || inactive? || outside_montevideo? || extension_module?
end

def average_rating
reviews.average(:rating).round(1) if reviews.any?
end

delegate :available?, to: :course
end
Loading

0 comments on commit aa55f7b

Please sign in to comment.