From f75e2fdb5803127bee3a616cfdffa94adc95cbad Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 6 Jun 2013 12:59:38 +0600 Subject: [PATCH 1/3] [#42] fix wrong render --- app/controllers/api/v1/issues_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/api/v1/issues_controller.rb b/app/controllers/api/v1/issues_controller.rb index 69de71330..37218b0b0 100644 --- a/app/controllers/api/v1/issues_controller.rb +++ b/app/controllers/api/v1/issues_controller.rb @@ -34,7 +34,6 @@ class Api::V1::IssuesController < Api::V1::BaseController end def show - respond_with @issue end def create @@ -94,7 +93,7 @@ class Api::V1::IssuesController < Api::V1::BaseController @issues = @issues.where('created_at >= to_timestamp(?)', params[:since]) if params[:since] =~ /\A\d+\z/ @issues.paginate(paginate_params) - respond_with @issues + render :index end def get_all_project_ids default_project_ids From 7d1f295e1852d7032bfde2e66469d9122a33fe1a Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 6 Jun 2013 13:02:25 +0600 Subject: [PATCH 2/3] [#42] add aliase to table in the sql request --- app/controllers/api/v1/issues_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/issues_controller.rb b/app/controllers/api/v1/issues_controller.rb index 37218b0b0..d6c712c02 100644 --- a/app/controllers/api/v1/issues_controller.rb +++ b/app/controllers/api/v1/issues_controller.rb @@ -64,9 +64,9 @@ class Api::V1::IssuesController < Api::V1::BaseController when 'none' @issues = @issues.where(:assigned_id => nil) when '*' - @issues = @issues.where('assigned_id IS NOT NULL') + @issues = @issues.where('issues.assigned_id IS NOT NULL') else - @issues = @issues.where('assignees_issues.uname = ?', params[:assignee]) + @issues = @issues.where('issues.assignees_issues.uname = ?', params[:assignee]) end end @@ -91,7 +91,7 @@ class Api::V1::IssuesController < Api::V1::BaseController direction = params[:direction] == 'asc' ? 'ASC' : 'DESC' @issues = @issues.order("#{sort} #{direction}") - @issues = @issues.where('created_at >= to_timestamp(?)', params[:since]) if params[:since] =~ /\A\d+\z/ + @issues = @issues.where('issues.created_at >= to_timestamp(?)', params[:since]) if params[:since] =~ /\A\d+\z/ @issues.paginate(paginate_params) render :index end From 5692c31c031853ed1657526b8ace002a122648db Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 10 Jun 2013 23:51:50 +0600 Subject: [PATCH 3/3] [#42] add specs for issues template --- spec/controllers/api/v1/issues_controller_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/controllers/api/v1/issues_controller_spec.rb b/spec/controllers/api/v1/issues_controller_spec.rb index 95082856a..8e307660a 100644 --- a/spec/controllers/api/v1/issues_controller_spec.rb +++ b/spec/controllers/api/v1/issues_controller_spec.rb @@ -40,6 +40,11 @@ describe Api::V1::IssuesController do response.should be_success end + it 'should render right template for show action' do + get :show, :project_id => @project.id, :id => @issue.serial_id, :format => :json + response.should render_template('api/v1/issues/show') + end + it 'can show issue in open project' do get :show, :project_id => @open_project.id, :id => @open_issue.serial_id, :format => :json response.should be_success @@ -62,12 +67,22 @@ describe Api::V1::IssuesController do assigns[:issues].should include(@membered_issue) end + it 'should render right template for all index action' do + get :all_index, :format => :json + response.should render_template('api/v1/issues/index') + end + it 'should return only assigned issue' do http_login(@issue.user) get :user_index, :format => :json assigns[:issues].should include(@own_hidden_issue) assigns[:issues].count.should == 1 end + + it 'should render right template for user index action' do + get :user_index, :format => :json + response.should render_template('api/v1/issues/index') + end end context 'for anonymous user' do