parent
64d6716a42
commit
317c85521f
@ -1 +0,0 @@
|
||||
UPGRADE TRIAL VIEW
|
@ -1,12 +0,0 @@
|
||||
require 'carto/db/migration_helper'
|
||||
|
||||
include Carto::Db::MigrationHelper
|
||||
|
||||
migration(
|
||||
Proc.new do
|
||||
add_column :users, :state, :text, default: 'active', null: false
|
||||
end,
|
||||
Proc.new do
|
||||
drop_column :users, :state
|
||||
end
|
||||
)
|
@ -0,0 +1,136 @@
|
||||
# encoding: utf-8
|
||||
require_relative '../acceptance_helper'
|
||||
|
||||
feature 'Dashboard' do
|
||||
background do
|
||||
@user = FactoryGirl.create(:user, :table_quota => 6)
|
||||
@tables = []
|
||||
@tables << FactoryGirl.create(:table, :user_id => @user.id, :tags => 'tag 1, wadus')
|
||||
@tables << FactoryGirl.create(:table, :user_id => @user.id, :tags => 'wadus')
|
||||
@tables << FactoryGirl.create(:table, :user_id => @user.id, :tags => 'tag 2')
|
||||
@tables << FactoryGirl.create(:table, :user_id => @user.id, :tags => 'tag 1, tag 2')
|
||||
@tables << FactoryGirl.create(:table, :user_id => @user.id, :tags => 'tag 2, wadus')
|
||||
end
|
||||
|
||||
scenario 'allows user to login and see their tables' do
|
||||
log_in_as(@user)
|
||||
|
||||
page.should have_content "Welcome #{@user.username}"
|
||||
page.should have_content '5 tables in your account'
|
||||
page.should have_css 'div.table_info div.left hgroup h3 a', :length => 5
|
||||
end
|
||||
|
||||
scenario 'allows users to browse their tables by tags' do
|
||||
log_in_as(@user)
|
||||
|
||||
page.should have_content '5 tables in your account'
|
||||
|
||||
click_on 'wadus'
|
||||
|
||||
page.should have_content '3 tables with tag wadus'
|
||||
|
||||
page.should have_link @tables[0].name
|
||||
page.should have_link @tables[1].name
|
||||
page.should have_link @tables[4].name
|
||||
|
||||
page.should_not have_link @tables[2].name
|
||||
page.should_not have_link @tables[3].name
|
||||
|
||||
click_on 'tag 1'
|
||||
|
||||
page.should have_content '2 tables with tag tag 1'
|
||||
|
||||
page.should have_link @tables[0].name
|
||||
page.should have_link @tables[3].name
|
||||
|
||||
page.should_not have_link @tables[1].name
|
||||
page.should_not have_link @tables[2].name
|
||||
page.should_not have_link @tables[4].name
|
||||
end
|
||||
|
||||
scenario 'allows users to remove a table' do
|
||||
log_in_as(@user)
|
||||
|
||||
page.should have_content '5 tables in your account'
|
||||
|
||||
within '.table_info' do
|
||||
click_on 'delete'
|
||||
end
|
||||
|
||||
expect do
|
||||
click_on 'Delete this table'
|
||||
end.to change{ Table.count }.from(5).to(4)
|
||||
|
||||
page.should have_content '4 tables in your account'
|
||||
end
|
||||
|
||||
scenario 'allows users to create a table with default attributes' do
|
||||
log_in_as(@user)
|
||||
|
||||
click_on 'Create a new table'
|
||||
|
||||
click_on 'Start from scratch'
|
||||
|
||||
expect do
|
||||
click_on 'Create table'
|
||||
sleep 3
|
||||
end.to change{ Table.count }.from(5).to(6)
|
||||
|
||||
created_table = Table.all.last
|
||||
|
||||
page.should have_link created_table.name
|
||||
|
||||
current_path.should match table_path(created_table)
|
||||
end
|
||||
|
||||
scenario 'shows users a link to upgrade their accounts' do
|
||||
log_in_as(@user)
|
||||
|
||||
page.should have_content "Hey #{@user.username}, looks like you're about to reach your account limit. Start thinking about upgrading your plan."
|
||||
|
||||
page.should have_link 'upgrading your plan', :href => "http://localhost:3000/account/#{@user.username}/upgrade"
|
||||
end
|
||||
|
||||
scenario 'allows users to obtain their security keys' do
|
||||
log_in_as(@user)
|
||||
|
||||
click_on @user.username
|
||||
|
||||
click_on 'Your API keys'
|
||||
|
||||
page.should have_content 'Your Api key'
|
||||
|
||||
click_on 'Request a new key'
|
||||
|
||||
click_on 'Regenerate Api key'
|
||||
|
||||
page.should have_content @user.api_key
|
||||
|
||||
click_on 'OAUTH'
|
||||
|
||||
click_on 'Request a new key'
|
||||
|
||||
click_on 'Regenerate Oauth and secret keys'
|
||||
|
||||
page.should have_content @user.client_application.key
|
||||
page.should have_content @user.client_application.secret
|
||||
|
||||
end
|
||||
|
||||
scenario 'allows users to create a table from a imported file'
|
||||
|
||||
scenario 'allows users to create a table from a URL pointing to a data file'
|
||||
|
||||
scenario 'allows to import a previously exported table as SHP (.zip extension)'
|
||||
|
||||
scenario 'allows to import a previously exported table as SHP (.tgz extension)'
|
||||
|
||||
scenario 'allows to import a previously exported table as SHP (.tar.gz extension)'
|
||||
|
||||
scenario 'allows to import a previously exported table as CSV'
|
||||
|
||||
scenario 'allows to import a previously exported table as KML'
|
||||
|
||||
scenario 'allows to import a previously exported table as SQL'
|
||||
end
|
||||
|
@ -1,254 +0,0 @@
|
||||
# encoding: utf-8
|
||||
|
||||
require_relative '../spec_helper'
|
||||
include Warden::Test::Helpers
|
||||
include Carto::Factories::Visualizations
|
||||
|
||||
def login(user)
|
||||
login_as(user, scope: user.username)
|
||||
host! "#{user.username}.localhost.lan"
|
||||
end
|
||||
|
||||
def follow_redirects(limit = 10)
|
||||
while response.redirect? && (limit -= 1) > 0
|
||||
follow_redirect!
|
||||
end
|
||||
end
|
||||
|
||||
describe "UserState" do
|
||||
|
||||
before(:all) do
|
||||
@locked_user = FactoryGirl.create(:locked_user)
|
||||
@map, @table, @table_visualization, @visualization = create_full_builder_vis(@locked_user)
|
||||
@visualization.create_mapcap!
|
||||
@non_locked_user = FactoryGirl.create(:valid_user)
|
||||
@dashboard_endpoints = ['/dashboard', '/dashboard/tables', '/dashboard/datasets', '/dashboard/visualizations',
|
||||
'/dashboard/maps'].freeze
|
||||
@public_user_endpoints = ['/me'].freeze
|
||||
@user_endpoints = ['/account', '/profile'].freeze
|
||||
@tables_endpoints = ["/tables/#{@table.id}", "/tables/#{@table.id}/public",
|
||||
"/tables/#{@table.id}/embed_map"].freeze
|
||||
@viz_endpoints = ["/viz/#{@visualization.id}/public",
|
||||
"/viz/#{@visualization.id}/embed_map", "/viz/#{@visualization.id}/public_map",
|
||||
"/builder/#{@visualization.id}", "/builder/#{@visualization.id}/embed"].freeze
|
||||
@public_api_endpoints = ["/api/v1/viz", "/api/v1/viz/#{@visualization.id}",
|
||||
"/api/v2/viz/#{@visualization.id}/viz",
|
||||
"/api/v3/me", "/api/v3/viz/#{@visualization.id}/viz"].freeze
|
||||
@private_api_endpoints = ["/api/v1/tables/#{@table.id}", "/api/v1/tables/#{@table.id}/columns",
|
||||
"/api/v1/imports", "/api/v1/users/#{@locked_user.id}/layers",
|
||||
"/api/v1/synchronizations", "/api/v1/geocodings",
|
||||
"/api/v1/users/#{@locked_user.id}"]
|
||||
@headers = {}
|
||||
@api_headers = { 'CONTENT_TYPE' => 'application/json', :format => "json" }
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@locked_user.destroy
|
||||
@non_locked_user.destroy
|
||||
end
|
||||
|
||||
describe '#locked user' do
|
||||
it 'owner accessing their resources' do
|
||||
login(@locked_user)
|
||||
@dashboard_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 302
|
||||
follow_redirect!
|
||||
request.path.should == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@user_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 302
|
||||
follow_redirect!
|
||||
request.path.should == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@public_user_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 302
|
||||
follow_redirect!
|
||||
request.path.should == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@tables_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 302
|
||||
follow_redirect!
|
||||
request.path.should == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@viz_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 302
|
||||
follow_redirect!
|
||||
request.path.should == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@private_api_endpoints.each do |endpoint|
|
||||
get "#{endpoint}?api_key=#{@locked_user.api_key}", {}, @api_headers
|
||||
request.path == endpoint
|
||||
response.status.should == 404
|
||||
end
|
||||
@public_api_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @api_headers
|
||||
request.path == endpoint
|
||||
response.status.should == 404
|
||||
end
|
||||
end
|
||||
it 'user accessing a locked user resources' do
|
||||
login(@non_locked_user)
|
||||
host! "#{@locked_user.username}.localhost.lan"
|
||||
@user_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 404
|
||||
end
|
||||
@public_user_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 404
|
||||
end
|
||||
@tables_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 404
|
||||
end
|
||||
@viz_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 404
|
||||
end
|
||||
@public_api_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @api_headers
|
||||
request.path == endpoint
|
||||
response.status.should == 404
|
||||
end
|
||||
end
|
||||
it 'non-logged user accessing a locked user resources' do
|
||||
host! "#{@locked_user.username}.localhost.lan"
|
||||
@public_user_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 404
|
||||
end
|
||||
@tables_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 404
|
||||
end
|
||||
@viz_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
response.status.should == 404
|
||||
end
|
||||
@public_api_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @api_headers
|
||||
request.path == endpoint
|
||||
response.status.should == 404
|
||||
end
|
||||
end
|
||||
end
|
||||
describe '#non locked user' do
|
||||
before(:all) do
|
||||
@locked_user.state = 'active'
|
||||
@locked_user.save
|
||||
end
|
||||
after(:all) do
|
||||
@locked_user.state = 'locked'
|
||||
@locked_user.save
|
||||
end
|
||||
it 'owner accessing their resources' do
|
||||
login(@locked_user)
|
||||
host! "#{@locked_user.username}.localhost.lan"
|
||||
@dashboard_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
request.path.should_not == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@user_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
request.path.should_not == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@public_user_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
request.path.should_not == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@tables_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
request.path.should_not == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@viz_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
request.path.should_not == '/upgrade_trial'
|
||||
response.status.should == 200
|
||||
end
|
||||
@private_api_endpoints.each do |endpoint|
|
||||
get "#{endpoint}?api_key=#{@locked_user.api_key}", {}, @api_headers
|
||||
request.path == endpoint
|
||||
response.status.should == 200
|
||||
end
|
||||
@public_api_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @api_headers
|
||||
request.path == endpoint
|
||||
response.status.should == 200
|
||||
end
|
||||
end
|
||||
it 'non locked user accessing a locked user resources' do
|
||||
login(@non_locked_user)
|
||||
@user_endpoints.each do |endpoint|
|
||||
host! "#{@locked_user.username}.localhost.lan"
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
response.status.should == 200
|
||||
end
|
||||
@public_user_endpoints.each do |endpoint|
|
||||
host! "#{@locked_user.username}.localhost.lan"
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
response.status.should == 200
|
||||
end
|
||||
@tables_endpoints.each do |endpoint|
|
||||
host! "#{@locked_user.username}.localhost.lan"
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
response.status.should == 200
|
||||
end
|
||||
@viz_endpoints.each do |endpoint|
|
||||
host! "#{@locked_user.username}.localhost.lan"
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
response.status.should == 200
|
||||
end
|
||||
@public_api_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @api_headers
|
||||
request.path == endpoint
|
||||
response.status.should == 200
|
||||
end
|
||||
end
|
||||
it 'non-logged user accessing a locked user resources' do
|
||||
host! "#{@locked_user.username}.localhost.lan"
|
||||
@public_user_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
response.status.should == 200
|
||||
end
|
||||
@tables_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
response.status.should == 200
|
||||
end
|
||||
@viz_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @headers
|
||||
follow_redirects
|
||||
response.status.should == 200
|
||||
end
|
||||
@public_api_endpoints.each do |endpoint|
|
||||
get endpoint, {}, @api_headers
|
||||
request.path == endpoint
|
||||
response.status.should == 200
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue