Fix undefined variable error on json project views
This mistake seems to have always been there, but it only resulted in errors on the `/explore*.json` since they were the one that _actually_ relied on the local variables.
This commit is contained in:
parent
a3b3da7277
commit
585fcfb9e7
7 changed files with 77 additions and 6 deletions
|
@ -15,7 +15,7 @@ class Admin::ProjectsController < Admin::ApplicationController
|
|||
format.html
|
||||
format.json do
|
||||
render json: {
|
||||
html: view_to_html_string("admin/projects/_projects", locals: { projects: @projects })
|
||||
html: view_to_html_string("admin/projects/_projects", projects: @projects)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
|
|||
end
|
||||
format.json do
|
||||
render json: {
|
||||
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
|
||||
html: view_to_html_string("dashboard/projects/_projects", projects: @projects)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
|
|||
format.html
|
||||
format.json do
|
||||
render json: {
|
||||
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
|
||||
html: view_to_html_string("dashboard/projects/_projects", projects: @projects)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ class Explore::ProjectsController < Explore::ApplicationController
|
|||
format.html
|
||||
format.json do
|
||||
render json: {
|
||||
html: view_to_html_string("explore/projects/_projects", locals: { projects: @projects })
|
||||
html: view_to_html_string("explore/projects/_projects", projects: @projects)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -30,7 +30,7 @@ class Explore::ProjectsController < Explore::ApplicationController
|
|||
format.html
|
||||
format.json do
|
||||
render json: {
|
||||
html: view_to_html_string("explore/projects/_projects", locals: { projects: @projects })
|
||||
html: view_to_html_string("explore/projects/_projects", projects: @projects)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -44,7 +44,7 @@ class Explore::ProjectsController < Explore::ApplicationController
|
|||
format.html
|
||||
format.json do
|
||||
render json: {
|
||||
html: view_to_html_string("explore/projects/_projects", locals: { projects: @projects })
|
||||
html: view_to_html_string("explore/projects/_projects", projects: @projects)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
5
changelogs/unreleased/fix-projects-partial-locals.yml
Normal file
5
changelogs/unreleased/fix-projects-partial-locals.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix undefined variable error on json project views
|
||||
merge_request: 26297
|
||||
author:
|
||||
type: fixed
|
|
@ -43,6 +43,16 @@ describe Admin::ProjectsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GET /projects.json' do
|
||||
render_views
|
||||
|
||||
before do
|
||||
get :index, format: :json
|
||||
end
|
||||
|
||||
it { is_expected.to respond_with(:success) }
|
||||
end
|
||||
|
||||
describe 'GET /projects/:id' do
|
||||
render_views
|
||||
|
||||
|
|
|
@ -2,4 +2,30 @@ require 'spec_helper'
|
|||
|
||||
describe Dashboard::ProjectsController do
|
||||
it_behaves_like 'authenticates sessionless user', :index, :atom
|
||||
|
||||
context 'json requests' do
|
||||
render_views
|
||||
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
describe 'GET /projects.json' do
|
||||
before do
|
||||
get :index, format: :json
|
||||
end
|
||||
|
||||
it { is_expected.to respond_with(:success) }
|
||||
end
|
||||
|
||||
describe 'GET /starred.json' do
|
||||
before do
|
||||
get :starred, format: :json
|
||||
end
|
||||
|
||||
it { is_expected.to respond_with(:success) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,36 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Explore::ProjectsController do
|
||||
describe 'GET #index.json' do
|
||||
render_views
|
||||
|
||||
before do
|
||||
get :index, format: :json
|
||||
end
|
||||
|
||||
it { is_expected.to respond_with(:success) }
|
||||
end
|
||||
|
||||
describe 'GET #trending.json' do
|
||||
render_views
|
||||
|
||||
before do
|
||||
get :trending, format: :json
|
||||
end
|
||||
|
||||
it { is_expected.to respond_with(:success) }
|
||||
end
|
||||
|
||||
describe 'GET #starred.json' do
|
||||
render_views
|
||||
|
||||
before do
|
||||
get :starred, format: :json
|
||||
end
|
||||
|
||||
it { is_expected.to respond_with(:success) }
|
||||
end
|
||||
|
||||
describe 'GET #trending' do
|
||||
context 'sorting by update date' do
|
||||
let(:project1) { create(:project, :public, updated_at: 3.days.ago) }
|
||||
|
|
Loading…
Reference in a new issue