Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e3dadb5
WIP: create feedback route
loiswells97 Oct 9, 2025
195eaaf
fixing
loiswells97 Oct 9, 2025
7e78390
Update feedback.rb
loiswells97 Oct 13, 2025
1dc0f11
improving feedback validations and adding factory and model tests
loiswells97 Oct 14, 2025
8fa4791
adding abilities
loiswells97 Oct 14, 2025
a560c73
testing feedback create operation
loiswells97 Oct 14, 2025
56f32da
tidying
loiswells97 Oct 14, 2025
1ec8287
initial rubocop fixes
loiswells97 Oct 14, 2025
1631cf9
Merge branch 'main' into create-feedback
loiswells97 Oct 16, 2025
826e1a4
updating schema version
loiswells97 Oct 16, 2025
788b447
remove unneeded test
loiswells97 Oct 16, 2025
8a1d61c
some rubocop fixes
loiswells97 Oct 16, 2025
054be3f
refactoring feedback factory to please rubocop
loiswells97 Oct 16, 2025
c57741d
adding authorisation for feedback creation
loiswells97 Oct 16, 2025
40ab7c5
add feedback auditing
loiswells97 Oct 16, 2025
7e1ea4a
tidying
loiswells97 Oct 16, 2025
3ad056b
tidying and request specs
loiswells97 Oct 17, 2025
581e3aa
rubocop fixes
loiswells97 Oct 17, 2025
59ecd17
adding comments to explain params
loiswells97 Oct 17, 2025
066ee40
removing commented code
loiswells97 Oct 17, 2025
5678604
fixing papertrail by adding meta migration to versions table
loiswells97 Oct 21, 2025
96c4b92
remove redundant operations directory
loiswells97 Oct 21, 2025
a3c612b
factoring out teacher project ids
loiswells97 Oct 22, 2025
8875291
factoring feedback template out into a partial
loiswells97 Oct 22, 2025
2adbcef
simplify feedback creation error handling
loiswells97 Oct 22, 2025
f08ba8c
Merge branch 'main' into create-feedback
loiswells97 Oct 22, 2025
1c801ae
refactor error handling slightly to catch non-validation errors
loiswells97 Oct 22, 2025
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
Prev Previous commit
Next Next commit
initial rubocop fixes
  • Loading branch information
loiswells97 committed Oct 14, 2025
commit 1ec8287414a358b9636506076513cc30710b07f7
4 changes: 3 additions & 1 deletion app/controllers/api/feedback_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Api
class FeedbackController < ApiController
before_action :authorize_user
Expand Down Expand Up @@ -31,7 +33,7 @@ def url_params

def base_params
params.fetch(:feedback, {}).permit(
:content,
:content
).merge(url_params)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/feedback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class Feedback < ApplicationRecord
belongs_to :school_project
validates :content, presence: true
validates :user_id, presence: true
validates :school_project, presence: true
validate :user_has_the_school_owner_or_school_teacher_role_for_the_school
validate :parent_project_belongs_to_lesson
validate :parent_project_belongs_to_school_class
Expand All @@ -25,6 +24,7 @@ def user_has_the_school_owner_or_school_teacher_role_for_the_school
def parent_project_belongs_to_lesson
parent_project = school_project&.project&.parent
return if parent_project&.lesson_id.present?

msg = "Parent project '#{parent_project&.id}' does not belong to a 'lesson'"
errors.add(:user, msg)
end
Expand Down
10 changes: 4 additions & 6 deletions lib/concepts/feedback/operations/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ def call(feedback_params:)
def build_feedback(feedback_hash)
project = Project.find_by(identifier: feedback_hash[:identifier])
school_project = project&.school_project
if school_project.nil?
raise "School project not found for identifier: #{feedback_hash[:identifier]}"
end
raise "School project not found for identifier: #{feedback_hash[:identifier]}" if school_project.nil?

# replace identifier with school_project_id
feedback_hash[:school_project_id] = school_project.id
feedback_hash.delete(:identifier)
new_feedback = Feedback.new(feedback_hash)
new_feedback
Feedback.new(feedback_hash)
end
end
end
end
end
4 changes: 3 additions & 1 deletion spec/factories/feedback.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# # frozen_string_literal: true

FactoryBot.define do
Expand All @@ -16,4 +18,4 @@
student_project { create(:project, parent: parent_project, user_id: student.id) }
end
end
end
end
4 changes: 2 additions & 2 deletions spec/models/feedback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
it 'validates that the user is the class teacher for the school project' do
school_class = create(:school_class, teacher_ids: [teacher.id], school:)
parent_project = create(:project, user_id: teacher.id, school:, lesson: create(:lesson, school:, school_class:, user_id: teacher.id))
school_project = create(:school_project, school:, project: create(:project, parent: parent_project))
school_project = create(:school_project, school:, project: create(:project, parent: parent_project))
other_teacher = create(:teacher, school:)
feedback = build(:feedback, school_project:, user_id: other_teacher.id)
expect(feedback).not_to be_valid
Expand All @@ -55,4 +55,4 @@
expect(feedback).to be_valid
end
end
end
end