Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Jan 2, 2025
1 parent 661bebd commit e80e5c9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def update
if labels
labels = labels&.split(',') unless labels.is_a?(Array)
labels = (labels + (@activity.merged_dirconfig[:labels] || []))
attributes[:labels] = labels&.map(&:downcase)&.uniq&.map { |name| Label.find_by(name: name) || Label.create(name: name) }
attributes[:labels] = labels.map(&:downcase).uniq.map { |name| Label.find_by(name: name) || Label.create(name: name) } if labels

Check warning on line 188 in app/controllers/activities_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/activities_controller.rb#L188

Added line #L188 was not covered by tests
end

respond_to do |format|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/course_members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def update
course_labels = attributes[:course_labels]
if course_labels
course_labels = course_labels.split(',') unless course_labels.is_a?(Array)
attributes[:course_labels] = course_labels&.map(&:downcase)&.uniq&.map { |name| CourseLabel.find_by(course: @course, name: name) || CourseLabel.create(course: @course, name: name) }
attributes[:course_labels] = course_labels.map(&:downcase).uniq.map { |name| CourseLabel.find_by(course: @course, name: name) || CourseLabel.create(course: @course, name: name) } if course_labels

Check warning on line 77 in app/controllers/course_members_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/course_members_controller.rb#L77

Added line #L77 was not covered by tests
end

if @course_membership.update(attributes)
Expand Down
7 changes: 5 additions & 2 deletions app/policies/evaluation_exercise_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def update?
private

def course_admin?
course = record&.evaluation&.series&.course
user&.course_admin?(course)
return false unless user
return false unless record

Check warning on line 21 in app/policies/evaluation_exercise_policy.rb

View check run for this annotation

Codecov / codecov/patch

app/policies/evaluation_exercise_policy.rb#L20-L21

Added lines #L20 - L21 were not covered by tests

course = record.evaluation.series.course
user.course_admin?(course)

Check warning on line 24 in app/policies/evaluation_exercise_policy.rb

View check run for this annotation

Codecov / codecov/patch

app/policies/evaluation_exercise_policy.rb#L23-L24

Added lines #L23 - L24 were not covered by tests
end
end
5 changes: 4 additions & 1 deletion app/policies/evaluation_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def permitted_attributes
private

def course_admin?
user&.course_admin?(record&.series&.course)
return false unless user
return false unless record

user.course_admin?(record.series.course)
end
end
5 changes: 4 additions & 1 deletion app/policies/feedback_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def permitted_attributes
private

def course_admin?
user&.course_admin?(record&.evaluation&.series&.course)
return false unless user
return false unless record

user.course_admin?(record.evaluation.series.course)
end
end
7 changes: 5 additions & 2 deletions app/policies/score_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def permitted_attributes_for_update
private

def course_admin?
course = record&.feedback&.evaluation&.series&.course
user&.course_admin?(course)
return false unless user
return false unless record

course = record.feedback.evaluation.series.course
user.course_admin?(course)
end
end

0 comments on commit e80e5c9

Please sign in to comment.