#465: Update specs

This commit is contained in:
Vokhmin Alexey V 2015-04-07 22:43:40 +03:00
parent 86bfd9b8c7
commit 0625a941bd
12 changed files with 29 additions and 27 deletions

View File

@ -37,7 +37,7 @@ class AutocompletesController < ApplicationController
def autocomplete_extra_repositories def autocomplete_extra_repositories
# Only personal and build for platform repositories can be attached to the build # Only personal and build for platform repositories can be attached to the build
platforms = PlatformPolicy::Scope.new(current_user, Platform).related. platforms = PlatformPolicy::Scope.new(current_user, Platform).show.
includes(:repositories).search(params[:term]).search_order.limit(5). includes(:repositories).search(params[:term]).search_order.limit(5).
where("platforms.platform_type = 'personal' OR platforms.id = ?", params[:build_for_platform_id]) where("platforms.platform_type = 'personal' OR platforms.id = ?", params[:build_for_platform_id])
platforms.each do |platform| platforms.each do |platform|

View File

@ -2,6 +2,7 @@ class SearchController < ApplicationController
include PaginateHelper include PaginateHelper
before_action :authenticate_user! unless APP_CONFIG['anonymous_access'] before_action :authenticate_user! unless APP_CONFIG['anonymous_access']
skip_after_action :verify_authorized
def index def index
@type = Search::TYPES.find{ |t| t == params[:type] } || Search::TYPES.first @type = Search::TYPES.find{ |t| t == params[:type] } || Search::TYPES.first

View File

@ -1,4 +1,5 @@
class SitemapController < ApplicationController class SitemapController < ApplicationController
skip_after_action :verify_authorized
def show def show
redirect_to "/sitemaps/#{request.host_with_port.gsub(/www./, '')}/sitemap.xml.gz" redirect_to "/sitemaps/#{request.host_with_port.gsub(/www./, '')}/sitemap.xml.gz"

View File

@ -132,7 +132,7 @@ class BuildList < ActiveRecord::Base
scope :recent, -> { order(updated_at: :desc) } scope :recent, -> { order(updated_at: :desc) }
scope :for_extra_build_lists, ->(ids, save_to_platform) { scope :for_extra_build_lists, ->(ids, save_to_platform) {
s = s.where(id: ids) s = where(id: ids, container_status: BuildList::BUILD_PUBLISHED)
s = s.where(save_to_platform_id: save_to_platform.id) if save_to_platform && save_to_platform.main? s = s.where(save_to_platform_id: save_to_platform.id) if save_to_platform && save_to_platform.main?
s s
} }

View File

@ -4,7 +4,7 @@ describe AdvisoriesController, type: :controller do
context 'for all' do context 'for all' do
it "should be able to perform search action" do it "should be able to perform search action" do
get :search get :search
response.should_not redirect_to(forbidden_path) expect(response).to_not redirect_to(forbidden_path)
end end
end end
end end

View File

@ -114,7 +114,7 @@ shared_examples_for 'api user with admin rights' do
#[:update, :destroy].each do |action| #[:update, :destroy].each do |action|
# it "ensures that return correct answer for wrong #{action} action" do # it "ensures that return correct answer for wrong #{action} action" do
# put action, id: nil, format: :json # put action, id: nil, format: :json
# response.status.should == 404 # expect(response.status).to eq 404
# end # end
#end #end
end end

View File

@ -11,12 +11,12 @@ describe AutocompletesController, type: :controller do
it 'should be able to perform autocomplete_user_or_group action' do it 'should be able to perform autocomplete_user_or_group action' do
get :autocomplete_user_or_group get :autocomplete_user_or_group
response.should be_success expect(response).to be_success
end end
it 'should be able to perform autocomplete_user_uname action' do it 'should be able to perform autocomplete_user_uname action' do
get :autocomplete_user_uname get :autocomplete_user_uname
response.should be_success expect(response).to be_success
end end
context 'autocomplete_extra_build_list' do context 'autocomplete_extra_build_list' do
@ -26,13 +26,13 @@ describe AutocompletesController, type: :controller do
it 'no data when build_list without container' do it 'no data when build_list without container' do
get :autocomplete_extra_build_list, params get :autocomplete_extra_build_list, params
response.body.should == '[]' expect(response.body).to eq '[]'
end end
it 'shows data when build_list with container' do it 'shows data when build_list with container' do
build_list.update_column(:container_status, BuildList::BUILD_PUBLISHED) build_list.update_column(:container_status, BuildList::BUILD_PUBLISHED)
get :autocomplete_extra_build_list, params get :autocomplete_extra_build_list, params
response.body.should_not == '[]' expect(response.body).to_not eq '[]'
end end
end end
@ -47,13 +47,13 @@ describe AutocompletesController, type: :controller do
it 'no data when repository of main platform' do it 'no data when repository of main platform' do
get :autocomplete_extra_repositories, params get :autocomplete_extra_repositories, params
response.body.should == '[]' expect(response.body).to eq '[]'
end end
it 'shows data when repository of personal platform' do it 'shows data when repository of personal platform' do
Platform.update_all(platform_type: 'personal') Platform.update_all(platform_type: 'personal')
get :autocomplete_extra_repositories, params get :autocomplete_extra_repositories, params
response.body.should_not == '[]' expect(response.body).to_not eq '[]'
end end
end end
@ -73,7 +73,7 @@ describe AutocompletesController, type: :controller do
].each do |action| ].each do |action|
it "should not be able to perform #{action} action" do it "should not be able to perform #{action} action" do
get action get action
response.should redirect_to(new_user_session_path) expect(response).to redirect_to(new_user_session_path)
end end
end end

View File

@ -267,7 +267,7 @@ describe Platforms::RepositoriesController, type: :controller do
it 'should not be able to perform projects_list action', anonymous_access: false do it 'should not be able to perform projects_list action', anonymous_access: false do
get :projects_list, id: @repository, platform_id: @platform, format: :json get :projects_list, id: @repository, platform_id: @platform, format: :json
response.response_code.should == 401 expect(response.response_code).to eq 401
end end
end end

View File

@ -30,7 +30,7 @@ describe Projects::Git::TreesController, type: :controller do
it "should not be able to perform archive action without anonymous acccess", anonymous_access: false do it "should not be able to perform archive action without anonymous acccess", anonymous_access: false do
get :archive, @params.merge(format: 'tar.gz') get :archive, @params.merge(format: 'tar.gz')
response.code.should == '401' expect(response.code).to eq '401'
end end
it 'should not be able to perform destroy action' do it 'should not be able to perform destroy action' do

View File

@ -3,14 +3,14 @@ require 'spec_helper'
shared_examples_for 'able search' do shared_examples_for 'able search' do
it 'should be able to search' do it 'should be able to search' do
get :index get :index
response.should be_success expect(response).to be_success
response.should render_template(:index) expect(response).to render_template(:index)
end end
end end
shared_examples_for 'not able search' do shared_examples_for 'not able search' do
it 'should not be able to search' do it 'should not be able to search' do
get :index get :index
response.should redirect_to(controller.current_user ? forbidden_path : new_user_session_path) expect(response).to redirect_to(controller.current_user ? forbidden_path : new_user_session_path)
end end
end end

View File

@ -5,8 +5,8 @@ describe SitemapController, type: :controller do
it 'is successful' do it 'is successful' do
get :robots get :robots
response.should be_success expect(response).to be_success
response.should render_template('sitemap/robots') expect(response).to render_template('sitemap/robots')
end end
context 'validate robots.txt' do context 'validate robots.txt' do
@ -14,12 +14,12 @@ describe SitemapController, type: :controller do
it 'ensures that Host is correct' do it 'ensures that Host is correct' do
get :robots get :robots
response.body.should match(/^Host: http:\/\/test.host$/) expect(response.body).to match(/^Host: http:\/\/test.host$/)
end end
it 'ensures that Sitemap is correct' do it 'ensures that Sitemap is correct' do
get :robots get :robots
response.body.should match(/^Sitemap: http:\/\/test.host\/sitemap.xml.gz$/) expect(response.body).to match(/^Sitemap: http:\/\/test.host\/sitemap.xml.gz$/)
end end
end end
end end
@ -28,7 +28,7 @@ describe SitemapController, type: :controller do
it 'is successful' do it 'is successful' do
get :show get :show
response.should redirect_to("/sitemaps/test.host/sitemap.xml.gz") expect(response).to redirect_to("/sitemaps/test.host/sitemap.xml.gz")
end end
end end

View File

@ -2,21 +2,21 @@ shared_examples_for 'an admin controller' do
it 'redirects to login when accessed unauthorised' do it 'redirects to login when accessed unauthorised' do
get :index get :index
response.should redirect_to(new_user_session_path) expect(response).to redirect_to(new_user_session_path)
end end
it 'raises a 404 for non-admin users' do it 'raises a 404 for non-admin users' do
user = User.first || FactoryGirl.create(:user) user = User.first || FactoryGirl.create(:user)
sign_in user sign_in user
get :index get :index
response.should render_template(file: "#{Rails.root}/public/404.html") expect(response).to render_template(file: "#{Rails.root}/public/404.html")
end end
it 'is successful for admin users' do it 'is successful for admin users' do
user = FactoryGirl.create(:admin) user = FactoryGirl.create(:admin)
sign_in user sign_in user
get :index get :index
response.should be_success expect(response).to be_success
end end
end end