#31: added specs for ProductBuildList#update action
This commit is contained in:
parent
7f1990bbb3
commit
9670f72ef9
|
@ -65,7 +65,7 @@ class Api::V1::BaseController < ApplicationController
|
|||
|
||||
def update_subject(subject)
|
||||
class_name = subject.class.name
|
||||
if subject.update_attributes(params[class_name.downcase.to_sym] || {})
|
||||
if subject.update_attributes(params[class_name.underscore.to_sym] || {})
|
||||
render_json_response subject, "#{class_name} has been updated successfully"
|
||||
else
|
||||
render_validation_error subject, "#{class_name} has not been updated"
|
||||
|
|
|
@ -38,7 +38,7 @@ class ProductBuildList < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
|
||||
# see: Issue #6
|
||||
before_validation lambda { self.arch_id = Arch.find_by_name('x86_64').id }
|
||||
before_validation lambda { self.arch_id = Arch.find_by_name('x86_64').id }, :on => :create
|
||||
validates :product_id,
|
||||
:status,
|
||||
:project_id,
|
||||
|
|
|
@ -64,7 +64,7 @@ shared_examples_for 'api user with admin rights' do
|
|||
params = {:product_id => @product_build_list.product_id, :arch_id => Arch.last.id,
|
||||
:commit_hash => commit_hash, :main_script => @product_build_list.main_script}
|
||||
@create_params = {:product_build_list =>{:time_living => 150}.merge(params)}
|
||||
@update_params = {:product_build_list =>{:time_living => 250}}
|
||||
@update_params = {:product_build_list =>{:time_living => 250, :not_delete => true}}
|
||||
end
|
||||
|
||||
it 'should be able to perform show action' do
|
||||
|
@ -96,14 +96,15 @@ shared_examples_for 'api user with admin rights' do
|
|||
lambda { put :destroy, :id => @product_build_list.id, :format => :json }.should change{ ProductBuildList.count }.by(-1)
|
||||
end
|
||||
|
||||
it "should not be able to perform update action" do
|
||||
put :update, :id => @product_build_list.id, :format => :json
|
||||
response.should_not be_success
|
||||
it "should be able to perform update action" do
|
||||
put :update, @update_params.merge(:id => @product_build_list.id), :format => :json
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it "ensures that product has not been updated" do
|
||||
it "ensures that only not_delete field of product build list has been updated" do
|
||||
put :update, @update_params.merge(:id => @product_build_list.id), :format => :json
|
||||
@product_build_list.reload.time_living.should == 150*60 # in seconds
|
||||
@product_build_list.not_delete.should be_true
|
||||
end
|
||||
|
||||
it 'ensures that return correct answer for wrong creating action' do
|
||||
|
|
|
@ -35,6 +35,18 @@ shared_examples_for 'product build list admin' do
|
|||
response.should render_template(:show)
|
||||
end
|
||||
|
||||
it 'should be able to perform update action' do
|
||||
put :update, valid_attributes_for_show.merge(:product_build_list => {:time_living => 100,:not_delete => true})
|
||||
response.should redirect_to(platform_product_product_build_list_path(@product.platform, @product, @pbl))
|
||||
end
|
||||
|
||||
it "ensures that only not_delete field of product build list has been updated" do
|
||||
put :update, valid_attributes_for_show.merge(:product_build_list => {:time_living => 100,:not_delete => true})
|
||||
time_living = @pbl.time_living
|
||||
@pbl.reload.time_living.should == time_living
|
||||
@pbl.not_delete.should be_true
|
||||
end
|
||||
|
||||
it 'should be able to perform log action' do
|
||||
get :log, valid_attributes_for_show
|
||||
response.should be_success
|
||||
|
|
Loading…
Reference in New Issue