Skip to content
Closed
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
3 changes: 2 additions & 1 deletion app/views/api/lessons/_lesson.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ if lesson.project
json.project(
lesson.project,
:identifier,
:project_type
:project_type,
:locale
)
end

Expand Down
27 changes: 27 additions & 0 deletions spec/features/lesson/creating_a_batch_of_lessons_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,33 @@
end
end

context 'when a locale is supplied for each project' do
let(:lesson_project_params) do
[
{
name: 'Lesson 1',
school_id: school.id,
project_attributes: { name: 'Project 1', project_type: Project::Types::CODE_EDITOR_SCRATCH, locale: 'fr-FR' }
},
{
name: 'Lesson 2',
school_id: school.id,
project_attributes: { name: 'Project 2', project_type: Project::Types::CODE_EDITOR_SCRATCH, locale: 'fr-FR' }
}
]
end

it 'persists the locale on each created project' do
expect(Project.where(locale: 'fr-FR').count).to eq(2)
end

it 'returns the locale on each project so callers can confirm it' do
data = JSON.parse(response.body, symbolize_names: true)

expect(data.map { |entry| entry.dig(:project, :locale) }).to all(eq('fr-FR'))
end
end

context 'when some entries are invalid' do
let(:lesson_projects) do
lesson_project_params + [{
Expand Down
2 changes: 1 addition & 1 deletion spec/features/lesson/listing_lessons_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
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)
expected_project = JSON.parse(lesson.project.to_json(only: %i[identifier project_type locale]), symbolize_names: true)

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