[refs #374] Fix some tests. Comment 500 error cautch
This commit is contained in:
parent
9712683c62
commit
554950a14c
|
@ -22,12 +22,12 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
if !Rails.env.development?
|
if !Rails.env.development?
|
||||||
rescue_from Exception do |exception|
|
#rescue_from Exception do |exception|
|
||||||
respond_to do |format|
|
# respond_to do |format|
|
||||||
format.json { render :json => {:message => t("flash.500_message")}.to_json }
|
# format.json { render :json => {:message => t("flash.500_message")}.to_json }
|
||||||
format.html { redirect_to '/500.html', :alert => t("flash.500_message") }
|
# format.html { redirect_to '/500.html', :alert => t("flash.500_message") }
|
||||||
end
|
# end
|
||||||
end
|
#end
|
||||||
|
|
||||||
rescue_from ActiveRecord::RecordNotFound,
|
rescue_from ActiveRecord::RecordNotFound,
|
||||||
ActionController::RoutingError,
|
ActionController::RoutingError,
|
||||||
|
|
|
@ -386,7 +386,9 @@ describe Api::V1::BuildListsController do
|
||||||
@build_list2 = FactoryGirl.create(:build_list_core)
|
@build_list2 = FactoryGirl.create(:build_list_core)
|
||||||
@build_list2.project.update_column(:visibility, 'hidden')
|
@build_list2.project.update_column(:visibility, 'hidden')
|
||||||
@build_list3 = FactoryGirl.create(:build_list_core)
|
@build_list3 = FactoryGirl.create(:build_list_core)
|
||||||
@build_list3.project.update_attributes({:owner => @user, :visibility => 'hidden'})
|
#@build_list3.project.update_attributes({:owner => @user, :visibility => 'hidden'})
|
||||||
|
@build_list3.project.update_column(:visibility, 'hidden')
|
||||||
|
project = @build_list3.project; project.owner = @user; project.save
|
||||||
@build_list4 = FactoryGirl.create(:build_list_core)
|
@build_list4 = FactoryGirl.create(:build_list_core)
|
||||||
@build_list4.project.update_column(:visibility, 'hidden')
|
@build_list4.project.update_column(:visibility, 'hidden')
|
||||||
@build_list4.project.relations.create :role => 'reader', :actor_id => @user.id, :actor_type => 'User'
|
@build_list4.project.relations.create :role => 'reader', :actor_id => @user.id, :actor_type => 'User'
|
||||||
|
@ -413,6 +415,25 @@ describe Api::V1::BuildListsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'for all build lists' do
|
||||||
|
before(:each) {
|
||||||
|
set_session_for(@user)
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'should be able to perform index action' do
|
||||||
|
get :index, :format => :json
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should show only accessible build_lists' do
|
||||||
|
get :index, :filter => {:ownership => 'index'}, :format => :json
|
||||||
|
assigns(:build_lists).should include(@build_list1)
|
||||||
|
assigns(:build_lists).should_not include(@build_list2)
|
||||||
|
assigns(:build_lists).should include(@build_list3)
|
||||||
|
assigns(:build_lists).should include(@build_list4)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'filter' do
|
context 'filter' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
set_session_for FactoryGirl.create(:admin)
|
set_session_for FactoryGirl.create(:admin)
|
||||||
|
@ -452,7 +473,6 @@ describe Api::V1::BuildListsController do
|
||||||
@project = @build_list.project
|
@project = @build_list.project
|
||||||
|
|
||||||
stub_symlink_methods
|
stub_symlink_methods
|
||||||
@user = FactoryGirl.create(:user)
|
|
||||||
@owner_user = @project.owner
|
@owner_user = @project.owner
|
||||||
@member_user = FactoryGirl.create(:user)
|
@member_user = FactoryGirl.create(:user)
|
||||||
@project.relations.create(:role => 'reader', :actor => @member_user)
|
@project.relations.create(:role => 'reader', :actor => @member_user)
|
||||||
|
@ -462,23 +482,6 @@ describe Api::V1::BuildListsController do
|
||||||
@show_params = {:id => @build_list.id, :format => :json}
|
@show_params = {:id => @build_list.id, :format => :json}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for all build lists' do
|
|
||||||
before(:each) {set_session_for(@user)}
|
|
||||||
|
|
||||||
it 'should be able to perform index action' do
|
|
||||||
get :index, :format => :json
|
|
||||||
response.should be_success
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should show only accessible build_lists' do
|
|
||||||
get :index, :filter => {:ownership => 'index'}, :format => :json
|
|
||||||
assigns(:build_lists).should include(@build_list1)
|
|
||||||
assigns(:build_lists).should_not include(@build_list2)
|
|
||||||
assigns(:build_lists).should include(@build_list3)
|
|
||||||
assigns(:build_lists).should include(@build_list4)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'for open project' do
|
context 'for open project' do
|
||||||
context 'for simple user' do
|
context 'for simple user' do
|
||||||
before(:each) {set_session_for(@user)}
|
before(:each) {set_session_for(@user)}
|
||||||
|
@ -522,11 +525,11 @@ describe Api::V1::BuildListsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@platform = FactoryGirl.create(:platform_with_repos)
|
@platform = FactoryGirl.create(:platform_with_repos)
|
||||||
@build_list = FactoryGirl.create(:build_list_core, :save_to_platform => @platform)
|
@build_list = FactoryGirl.create(:build_list_core, :save_to_platform => @platform)
|
||||||
|
@project = @build_list.project
|
||||||
@params = @build_list.attributes.symbolize_keys
|
@params = @build_list.attributes.symbolize_keys
|
||||||
|
|
||||||
stub_symlink_methods
|
stub_symlink_methods
|
||||||
@user = FactoryGirl.create(:user)
|
@owner_user = @project.owner#FactoryGirl.create(:user)
|
||||||
@owner_user = FactoryGirl.create(:user)
|
|
||||||
@member_user = FactoryGirl.create(:user)
|
@member_user = FactoryGirl.create(:user)
|
||||||
#@project.relations.create(:role => 'reader', :actor => @member_user)
|
#@project.relations.create(:role => 'reader', :actor => @member_user)
|
||||||
|
|
||||||
|
@ -540,31 +543,13 @@ describe Api::V1::BuildListsController do
|
||||||
@group = FactoryGirl.create(:group)
|
@group = FactoryGirl.create(:group)
|
||||||
@group.actors.create :role => 'reader', :actor_id => @user.id, :actor_type => 'User'
|
@group.actors.create :role => 'reader', :actor_id => @user.id, :actor_type => 'User'
|
||||||
|
|
||||||
@project = FactoryGirl.create(:project, :owner => @owner_group, :repositories => @platform.repositories)
|
#@project = FactoryGirl.create(:project, :owner => @owner_group, :repositories => @platform.repositories)
|
||||||
|
|
||||||
#@project.owner = @owner_group
|
#@project.owner = @owner_group
|
||||||
#@project.save
|
#@project.save
|
||||||
#@project.relations.create :role => 'reader', :actor_id => @member_group.id, :actor_type => 'Group'
|
@project.relations.create :role => 'reader', :actor_id => @member_group.id, :actor_type => 'Group'
|
||||||
@build_list.save_to_platform.relations.create(:role => 'reader', :actor => @member_group) # Why it's really need it??
|
#@build_list.save_to_platform.relations.create(:role => 'reader', :actor => @member_group) # Why it's really need it??
|
||||||
@build_list.save_to_platform.relations.create(:role => 'admin', :actor => @owner_group) # Why it's really need it??
|
#@build_list.save_to_platform.relations.create(:role => 'admin', :actor => @owner_group) # Why it's really need it??
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
context 'for all build lists' do
|
|
||||||
before(:each) {set_session_for(@user)}
|
|
||||||
|
|
||||||
it 'should be able to perform index action' do
|
|
||||||
get :index, :format => :json
|
|
||||||
response.should be_success
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should show only accessible build_lists' do
|
|
||||||
get :index, :filter => {:ownership => 'index'}, :format => :json
|
|
||||||
assigns(:build_lists).should include(@build_list1)
|
|
||||||
assigns(:build_lists).should_not include(@build_list2)
|
|
||||||
assigns(:build_lists).should include(@build_list3)
|
|
||||||
assigns(:build_lists).should include(@build_list4)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for open project' do
|
context 'for open project' do
|
||||||
|
@ -595,7 +580,7 @@ describe Api::V1::BuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'if user is group owner' do
|
context 'if user is group owner' do
|
||||||
before(:each) {set_session_for(@owner_user)}
|
before(:each) { set_session_for(@owner_user) }
|
||||||
it_should_behave_like 'show build list'
|
it_should_behave_like 'show build list'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue