Skip to content

Commit

Permalink
In redmine 2.1 406 Not acceptable occurred.
Browse files Browse the repository at this point in the history
  • Loading branch information
kawasima committed Sep 24, 2012
1 parent 42653c9 commit e6acef6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 74 deletions.
27 changes: 9 additions & 18 deletions app/controllers/impasse_executions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ def put
end
end

respond_to do |format|
if errors.empty?
format.json { render :json => { :status => 'success', :message => l(:notice_successful_update) } }
else
format.json { render :json => { :status => 'error', :message => l(:error_failed_to_update), :errors => errors } }
end
if errors.empty?
render :json => { :status => 'success', :message => l(:notice_successful_update) }
else
render :json => { :status => 'error', :message => l(:error_failed_to_update), :errors => errors }
end
end

Expand All @@ -77,18 +75,14 @@ def destroy
satus &= execution.save
end

respond_to do |format|
format.json { render :json => { :status => status } }
end
render :json => { :status => status }
end

def get_list
nodes = Impasse::Node.find_planned(params[:id], params[:test_plan_id], params[:filters] || {})
jstree_nodes = convert(nodes, params[:prefix])

respond_to do |format|
format.json { render :json => jstree_nodes }
end
render :json => jstree_nodes
end

def edit
Expand All @@ -114,12 +108,9 @@ def edit
:conditions => ["test_plan_case_id=?", @execution.test_plan_case_id],
:order => "execution_ts DESC")
if request.post? and @execution.save
respond_to do |format|
format.json { render :json => {'status'=>true} }
end
end
respond_to do |format|
format.html { render :partial=>'edit' }
render :json => {'status'=>true}
else
render :partial=>'edit'
end
end

Expand Down
4 changes: 1 addition & 3 deletions app/controllers/impasse_requirement_issues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def index
:limit => @limit)
@issue_count_by_group = @query.issue_count_by_group

respond_to do |format|
format.html { render :index, :layout => !request.xhr? }
end
render :index, :layout => !request.xhr?
end
rescue ActiveRecord::RecordNotFound
render_404
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/impasse_screenshots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def show
def destroy
@attachment = Attachment.find(params[:attachment_id])
@attachment.destroy
respond_to do |format|
format.json { render :json => { :status => 'success' } }
end
render :json => { :status => 'success' }
end
end
68 changes: 24 additions & 44 deletions app/controllers/impasse_test_case_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,14 @@ def list
end
jstree_nodes = convert(@nodes, params[:prefix])

respond_to do |format|
format.json { render :json => jstree_nodes }
end
render :json => jstree_nodes
end

def show
@node, @test_case = get_node(params[:node])
@setting = Impasse::Setting.find_by_project_id(@project) || Impasse::Setting.create(:project_id => @project.id)

respond_to do |format|
format.html { render :partial => 'show' }
end
render :partial => 'show'
end

def new
Expand All @@ -59,23 +55,19 @@ def new
@test_case.test_steps.replace(@test_steps)
end
@test_case.save!
respond_to do |format|
format.json { render :json => { :status => 'success', :message => l(:notice_successful_create), :ids => [@test_case.id] } }
end
render :json => { :status => 'success', :message => l(:notice_successful_create), :ids => [@test_case.id] }
end
rescue ActiveRecord::ActiveRecordError => e
respond_to do |format|
errors = []
errors.concat(@node.errors.full_messages).concat(@test_case.errors.full_messages)
if @test_steps
@test_steps.each {|test_step|
test_step.errors.full_messages.each {|msg|
errors << "##{test_step.step_number} #{msg}"
}
errors = []
errors.concat(@node.errors.full_messages).concat(@test_case.errors.full_messages)
if @test_steps
@test_steps.each {|test_step|
test_step.errors.full_messages.each {|msg|
errors << "##{test_step.step_number} #{msg}"
}
end
format.json { render :json => { :errors => errors }}
}
end
render :json => { :errors => errors }
end
else
render :partial => "new"
Expand All @@ -94,9 +86,7 @@ def copy
end
end

respond_to do |format|
format.json { render :json => nodes }
end
render :json => nodes
end

def move
Expand All @@ -109,9 +99,7 @@ def move
end
end

respond_to do |format|
format.json { render :json => nodes }
end
render :json => nodes
end

def edit
Expand All @@ -137,23 +125,19 @@ def edit
create_thumbnail(attachments) if Object.const_defined?(:Magick)
end

respond_to do |format|
format.json { render :json => { :status => 'success', :message => l(:notice_successful_update), :ids => [@test_case.id] } }
end
render :json => { :status => 'success', :message => l(:notice_successful_update), :ids => [@test_case.id] }
end
rescue ActiveRecord::ActiveRecordError=> e
respond_to do |format|
errors = []
errors.concat(@node.errors.full_messages).concat(@test_case.errors.full_messages)
if @test_steps
@test_steps.each {|test_step|
test_step.errors.full_messages.each {|msg|
errors << "##{test_step.step_number} #{msg}"
}
errors = []
errors.concat(@node.errors.full_messages).concat(@test_case.errors.full_messages)
if @test_steps
@test_steps.each {|test_step|
test_step.errors.full_messages.each {|msg|
errors << "##{test_step.step_number} #{msg}"
}
end
format.json { render :json => { :errors => errors }}
}
end
render :json => { :errors => errors }
end
else
render :partial => 'edit'
Expand Down Expand Up @@ -186,16 +170,12 @@ def destroy
end
end

respond_to do |format|
format.json { render :json => {:status => true} }
end
render :json => {:status => true}
end

def keywords
keywords = Impasse::Keyword.find_all_by_project_id(@project).map{|r| r.keyword}
respond_to do |format|
format.json { render :json => keywords }
end
render :json => keywords
end

def copy_to_another_project
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/impasse_test_plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,12 @@ def add_test_case
end
end

respond_to do |format|
format.json { render :json => { :status => 'success', :message => l(:notice_successful_create) } }
end
render :json => { :status => 'success', :message => l(:notice_successful_create) }
end

def remove_test_case
Impasse::TestPlanCase.delete_cascade!(params[:test_plan_id], params[:test_case_id])
respond_to do |format|
format.json { render :json => { :status => 'success', :message => l(:notice_successful_delete) } }
end
render :json => { :status => 'success', :message => l(:notice_successful_delete) }
end

def autocomplete
Expand Down

0 comments on commit e6acef6

Please sign in to comment.