avoid using static pages in tests

stub static pages
pull/14113/head
Alberto Romeu 6 years ago
parent a79e1dac60
commit abd33fc848

@ -206,6 +206,9 @@ describe Admin::PagesController do
end
it 'extracts username from redirection for dashboard with subdomainless' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
username = 'endedwithu'
anyuser = prepare_user(username)
host! 'localhost.lan'

@ -44,6 +44,9 @@ describe Admin::TablesController do
describe 'GET /dashboard' do
it 'returns a list of tables' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
login_as(@user, scope: @user.username)
get "/dashboard", {}, @headers

@ -47,10 +47,12 @@ describe ApplicationController do
end
it 'loads the dashboard for a known user email' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
stub_load_common_data
get dashboard_url, {}, authentication_headers(@user.email)
response.status.should == 200
response.body.should_not include("Log in")
end
it 'does not load the dashboard for an unknown user email' do
@ -70,10 +72,12 @@ describe ApplicationController do
end
it 'loads the dashboard for a known user username' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
stub_load_common_data
get dashboard_url, {}, authentication_headers(@user.username)
response.status.should == 200
response.body.should_not include("Log in")
end
it 'does not load the dashboard for an unknown user username' do
@ -93,10 +97,12 @@ describe ApplicationController do
end
it 'loads the dashboard for a known user id' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
stub_load_common_data
get dashboard_url, {}, authentication_headers(@user.id)
response.status.should == 200
response.body.should_not include("Log in")
end
it 'does not load the dashboard for an unknown user id' do
@ -116,24 +122,30 @@ describe ApplicationController do
end
it 'loads the dashboard for a known user id' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
stub_load_common_data
get dashboard_url, {}, authentication_headers(@user.id)
response.status.should == 200
response.body.should_not include("Log in")
end
it 'loads the dashboard for a known user username' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
stub_load_common_data
get dashboard_url, {}, authentication_headers(@user.username)
response.status.should == 200
response.body.should_not include("Log in")
end
it 'loads the dashboard for a known user email' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
stub_load_common_data
get dashboard_url, {}, authentication_headers(@user.email)
response.status.should == 200
response.body.should_not include("Log in")
end
it 'does not load the dashboard for an unknown user id' do

@ -313,6 +313,9 @@ describe SessionsController do
end
it "authenticates users with casing differences in email" do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
Carto::SamlService.any_instance.stubs(:enabled?).returns(true)
Carto::SamlService.any_instance.stubs(:get_user_email).returns(@user.email.upcase)

@ -39,6 +39,9 @@ feature "Sessions" do
end
scenario "Login in the application" do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
SessionsController.any_instance.stubs(:central_enabled?).returns(false)
visit login_path
fill_in 'email', :with => @user.email
@ -51,7 +54,10 @@ feature "Sessions" do
fill_in 'email', :with => @user.email
fill_in 'password', :with => @user.email.split('@').first
click_link_or_button 'Log in'
page.should have_content('window.StaticConfig = {"page":"dashboard"')
page.status_code.should eq 200
page.should_not have_css(".Sessions-fieldError.js-Sessions-fieldError")
page.should_not have_css("[@data-content='Your account or your password is not ok']")
end
scenario "Get the session information via OAuth" do
@ -114,9 +120,14 @@ feature "Sessions" do
include_context 'organization with users helper'
it 'allows login to organization users' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
visit org_login_url(@org_user_1.organization)
send_login_form(@org_user_1)
page.should have_content('window.StaticConfig = {"page":"dashboard"')
page.status_code.should eq 200
page.should_not have_css(".Sessions-fieldError.js-Sessions-fieldError")
end
it 'does not allow user+password login to organization users if auth_username_password_enabled is false' do

@ -2,7 +2,7 @@
require_relative '../acceptance_helper'
feature "Tables", :js => true do
before do
before do
@user = FactoryGirl.create(:user_with_private_tables)
@table = FactoryGirl.create(:table, :user_id => @user.id,
:name => 'Twitter followers',

@ -109,7 +109,7 @@ describe "UserState" do
to_be_deleted_user.save
login(to_be_deleted_user)
delete account_delete_user_url, deletion_password_confirmation: 'pwd123'
delete api_v3_users_delete_me_url, deletion_password_confirmation: 'pwd123'
expect(User.find(id: to_be_deleted_user.id)).to be_nil
end
@ -178,7 +178,10 @@ describe "UserState" do
@locked_user.save
end
it 'owner accessing their resources' do
# we use this to avoid generating the static assets in CI
Admin::UsersController.any_instance.stubs(:render)
Admin::VisualizationsController.any_instance.stubs(:render)
login(@locked_user)
host! "#{@locked_user.username}.localhost.lan"
@dashboard_endpoints.each do |endpoint|
@ -223,6 +226,9 @@ describe "UserState" do
end
end
it 'non locked user accessing a locked user resources' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render)
login(@non_locked_user)
@user_endpoints.each do |endpoint|
host! "#{@locked_user.username}.localhost.lan"

@ -74,6 +74,9 @@ describe 'Warden' do
end
it 'allows access for non-expired session' do
# we use this to avoid generating the static assets in CI
Admin::VisualizationsController.any_instance.stubs(:render).returns('')
Cartodb.with_config(passwords: { 'expiration_in_d' => nil }) do
login

Loading…
Cancel
Save