#465: Update specs
This commit is contained in:
parent
86bfd9b8c7
commit
0625a941bd
|
@ -37,7 +37,7 @@ class AutocompletesController < ApplicationController
|
|||
|
||||
def autocomplete_extra_repositories
|
||||
# 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).
|
||||
where("platforms.platform_type = 'personal' OR platforms.id = ?", params[:build_for_platform_id])
|
||||
platforms.each do |platform|
|
||||
|
|
|
@ -2,6 +2,7 @@ class SearchController < ApplicationController
|
|||
include PaginateHelper
|
||||
|
||||
before_action :authenticate_user! unless APP_CONFIG['anonymous_access']
|
||||
skip_after_action :verify_authorized
|
||||
|
||||
def index
|
||||
@type = Search::TYPES.find{ |t| t == params[:type] } || Search::TYPES.first
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class SitemapController < ApplicationController
|
||||
skip_after_action :verify_authorized
|
||||
|
||||
def show
|
||||
redirect_to "/sitemaps/#{request.host_with_port.gsub(/www./, '')}/sitemap.xml.gz"
|
||||
|
@ -8,4 +9,4 @@ class SitemapController < ApplicationController
|
|||
render file: 'sitemap/robots', layout: false, content_type: Mime::TEXT
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -132,7 +132,7 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
scope :recent, -> { order(updated_at: :desc) }
|
||||
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
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ describe AdvisoriesController, type: :controller do
|
|||
context 'for all' do
|
||||
it "should be able to perform search action" do
|
||||
get :search
|
||||
response.should_not redirect_to(forbidden_path)
|
||||
expect(response).to_not redirect_to(forbidden_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -114,7 +114,7 @@ shared_examples_for 'api user with admin rights' do
|
|||
#[:update, :destroy].each do |action|
|
||||
# it "ensures that return correct answer for wrong #{action} action" do
|
||||
# put action, id: nil, format: :json
|
||||
# response.status.should == 404
|
||||
# expect(response.status).to eq 404
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
|
|
@ -11,12 +11,12 @@ describe AutocompletesController, type: :controller do
|
|||
|
||||
it 'should be able to perform autocomplete_user_or_group action' do
|
||||
get :autocomplete_user_or_group
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it 'should be able to perform autocomplete_user_uname action' do
|
||||
get :autocomplete_user_uname
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
context 'autocomplete_extra_build_list' do
|
||||
|
@ -26,13 +26,13 @@ describe AutocompletesController, type: :controller do
|
|||
|
||||
it 'no data when build_list without container' do
|
||||
get :autocomplete_extra_build_list, params
|
||||
response.body.should == '[]'
|
||||
expect(response.body).to eq '[]'
|
||||
end
|
||||
|
||||
it 'shows data when build_list with container' do
|
||||
build_list.update_column(:container_status, BuildList::BUILD_PUBLISHED)
|
||||
get :autocomplete_extra_build_list, params
|
||||
response.body.should_not == '[]'
|
||||
expect(response.body).to_not eq '[]'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -47,13 +47,13 @@ describe AutocompletesController, type: :controller do
|
|||
|
||||
it 'no data when repository of main platform' do
|
||||
get :autocomplete_extra_repositories, params
|
||||
response.body.should == '[]'
|
||||
expect(response.body).to eq '[]'
|
||||
end
|
||||
|
||||
it 'shows data when repository of personal platform' do
|
||||
Platform.update_all(platform_type: 'personal')
|
||||
get :autocomplete_extra_repositories, params
|
||||
response.body.should_not == '[]'
|
||||
expect(response.body).to_not eq '[]'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -73,7 +73,7 @@ describe AutocompletesController, type: :controller do
|
|||
].each do |action|
|
||||
it "should not be able to perform #{action} action" do
|
||||
get action
|
||||
response.should redirect_to(new_user_session_path)
|
||||
expect(response).to redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ describe Platforms::RepositoriesController, type: :controller 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
|
||||
response.response_code.should == 401
|
||||
expect(response.response_code).to eq 401
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -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
|
||||
get :archive, @params.merge(format: 'tar.gz')
|
||||
response.code.should == '401'
|
||||
expect(response.code).to eq '401'
|
||||
end
|
||||
|
||||
it 'should not be able to perform destroy action' do
|
||||
|
|
|
@ -3,14 +3,14 @@ require 'spec_helper'
|
|||
shared_examples_for 'able search' do
|
||||
it 'should be able to search' do
|
||||
get :index
|
||||
response.should be_success
|
||||
response.should render_template(:index)
|
||||
expect(response).to be_success
|
||||
expect(response).to render_template(:index)
|
||||
end
|
||||
end
|
||||
shared_examples_for 'not able search' do
|
||||
it 'should not be able to search' do
|
||||
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
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ describe SitemapController, type: :controller do
|
|||
|
||||
it 'is successful' do
|
||||
get :robots
|
||||
response.should be_success
|
||||
response.should render_template('sitemap/robots')
|
||||
expect(response).to be_success
|
||||
expect(response).to render_template('sitemap/robots')
|
||||
end
|
||||
|
||||
context 'validate robots.txt' do
|
||||
|
@ -14,12 +14,12 @@ describe SitemapController, type: :controller do
|
|||
|
||||
it 'ensures that Host is correct' do
|
||||
get :robots
|
||||
response.body.should match(/^Host: http:\/\/test.host$/)
|
||||
expect(response.body).to match(/^Host: http:\/\/test.host$/)
|
||||
end
|
||||
|
||||
it 'ensures that Sitemap is correct' do
|
||||
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
|
||||
|
@ -28,7 +28,7 @@ describe SitemapController, type: :controller do
|
|||
|
||||
it 'is successful' do
|
||||
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
|
||||
|
|
|
@ -2,21 +2,21 @@ shared_examples_for 'an admin controller' do
|
|||
|
||||
it 'redirects to login when accessed unauthorised' do
|
||||
get :index
|
||||
response.should redirect_to(new_user_session_path)
|
||||
expect(response).to redirect_to(new_user_session_path)
|
||||
end
|
||||
|
||||
it 'raises a 404 for non-admin users' do
|
||||
user = User.first || FactoryGirl.create(:user)
|
||||
sign_in user
|
||||
get :index
|
||||
response.should render_template(file: "#{Rails.root}/public/404.html")
|
||||
expect(response).to render_template(file: "#{Rails.root}/public/404.html")
|
||||
end
|
||||
|
||||
it 'is successful for admin users' do
|
||||
user = FactoryGirl.create(:admin)
|
||||
sign_in user
|
||||
get :index
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue