Skip to content
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
8 changes: 8 additions & 0 deletions app/views/api/lessons/index.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,13 @@ json.array!(@lessons_with_users) do |lesson, user|
:updated_at
)

if lesson.project
json.project(
lesson.project,
:identifier,
:project_type
)
end
Comment on lines +20 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a test for this? No worries though if it's going to get complex 😅


json.user_name(user&.name)
end
1 change: 1 addition & 0 deletions app/views/api/my_school/show.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ json.call(
:administrative_area,
:postal_code,
:country_code,
:code,
:verified_at,
:created_at,
:updated_at
Expand Down
8 changes: 8 additions & 0 deletions spec/features/lesson/listing_lessons_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
expect(data.first[:user_name]).to eq('School Teacher')
end

it 'responds with the project JSON' do
get('/api/lessons', headers:)
data = JSON.parse(response.body, symbolize_names: true)
expected_project = JSON.parse(lesson.project.to_json(only: %i[identifier project_type]), symbolize_names: true)

expect(data.first[:project]).to eq(expected_project)
end

# rubocop:disable RSpec/ExampleLength
it "responds with nil attributes for the user if their user profile doesn't exist" do
user_id = SecureRandom.uuid
Expand Down
2 changes: 1 addition & 1 deletion spec/features/my_school/showing_my_school_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
end

it "includes the school details and user's roles in the JSON" do
school_json = school.to_json(only: %i[id name website reference address_line_1 address_line_2 municipality administrative_area postal_code country_code verified_at created_at updated_at])
school_json = school.to_json(only: %i[id name website reference address_line_1 address_line_2 municipality administrative_area postal_code country_code code verified_at created_at updated_at])
expected_data = JSON.parse(school_json, symbolize_names: true).merge(roles: ['owner'])

get('/api/school', headers:)
Expand Down