Commit 3c5a81cb authored by Stan Hu's avatar Stan Hu

Merge branch 'fix-projects-partial-locals' into 'master'

Fix undefined variable error on json project views

See merge request gitlab-org/gitlab-ce!26297
parents a3b3da72 585fcfb9
...@@ -15,7 +15,7 @@ class Admin::ProjectsController < Admin::ApplicationController ...@@ -15,7 +15,7 @@ class Admin::ProjectsController < Admin::ApplicationController
format.html format.html
format.json do format.json do
render json: { 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
end end
......
...@@ -26,7 +26,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController ...@@ -26,7 +26,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
end end
format.json do format.json do
render json: { 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
end end
...@@ -43,7 +43,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController ...@@ -43,7 +43,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
format.html format.html
format.json do format.json do
render json: { 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
end end
......
...@@ -15,7 +15,7 @@ class Explore::ProjectsController < Explore::ApplicationController ...@@ -15,7 +15,7 @@ class Explore::ProjectsController < Explore::ApplicationController
format.html format.html
format.json do format.json do
render json: { 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
end end
...@@ -30,7 +30,7 @@ class Explore::ProjectsController < Explore::ApplicationController ...@@ -30,7 +30,7 @@ class Explore::ProjectsController < Explore::ApplicationController
format.html format.html
format.json do format.json do
render json: { 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
end end
...@@ -44,7 +44,7 @@ class Explore::ProjectsController < Explore::ApplicationController ...@@ -44,7 +44,7 @@ class Explore::ProjectsController < Explore::ApplicationController
format.html format.html
format.json do format.json do
render json: { 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
end end
......
---
title: Fix undefined variable error on json project views
merge_request: 26297
author:
type: fixed
...@@ -43,6 +43,16 @@ describe Admin::ProjectsController do ...@@ -43,6 +43,16 @@ describe Admin::ProjectsController do
end end
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 describe 'GET /projects/:id' do
render_views render_views
......
...@@ -2,4 +2,30 @@ require 'spec_helper' ...@@ -2,4 +2,30 @@ require 'spec_helper'
describe Dashboard::ProjectsController do describe Dashboard::ProjectsController do
it_behaves_like 'authenticates sessionless user', :index, :atom 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 end
require 'spec_helper' require 'spec_helper'
describe Explore::ProjectsController do 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 describe 'GET #trending' do
context 'sorting by update date' do context 'sorting by update date' do
let(:project1) { create(:project, :public, updated_at: 3.days.ago) } let(:project1) { create(:project, :public, updated_at: 3.days.ago) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment