working json api acceptance tests

2.0
Simon Tokumine 12 years ago
parent c518667459
commit 9810ede714

@ -60,7 +60,8 @@ class ApplicationController < ActionController::Base
authenticated?(request.subdomain) || not_authorized
end
def api_authorization_required
def api_authorization_required
Rails.logger.info "MAH LOVERLY COOKIE #{cookies}"
authenticate!(:api_key, :api_authentication, :scope => request.subdomain)
end

@ -1,39 +0,0 @@
development:
session_domain: '.localhost.lan'
secret_token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
account_host: 'localhost.lan:4000'
account_path: '/account'
tile_host: 'localhost.lan'
tile_port: '8181'
developers_host: 'http://developers.localhost.lan:3000'
secret_token: "some_secret"
amazon_access_key: ''
amazon_secret_key: ''
varnish_management:
host: '127.0.0.1'
post: 6082
redis:
host: '127.0.0.1'
port: 6379
superadmin:
username: "superadmin"
password: "monkey"
test:
session_domain: '.localhost.lan'
secret_token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
account_host: 'testhost.lan'
account_path: '/account'
developers_host: 'http://developers.testhost.lan:53716'
secret_token: "some_secret"
amazon_access_key: ''
amazon_secret_key: ''
varnish_management:
host: '127.0.0.1'
post: 6082
redis:
host: '127.0.0.1'
port: 6380
superadmin:
username: "superadmin"
password: "monkeytest"

@ -1,27 +0,0 @@
production:
adapter: postgres
encoding: unicode
host: localhost
port: 5432
database: carto_db_production
username: postgres
password:
development:
adapter: postgres
encoding: unicode
host: localhost
port: 5432
database: carto_db_development
username: postgres
password:
test:
adapter: postgres
encoding: unicode
database: carto_db_test
host: localhost
port: 5432
username: postgres
password:

@ -14,7 +14,7 @@ module CartoDB
elsif Rails.env.development?
"vizzuality#{session_domain}"
else
"vizzuality#{session_domain}"
"test#{session_domain}"
end
end

@ -6,13 +6,11 @@ feature "API 1.0 columns management" do
background do
Capybara.current_driver = :rack_test
@user = create_user
@user = create_user({:username => 'test'})
@table = create_table :user_id => @user.id
login_as @user
end
scenario "Get the columns from a table" do
scenario "Get the columns from a table" do
get_json api_table_columns_url(@table.name) do |response|
response.status.should be_success
(response.body - default_schema).should be_empty

@ -8,7 +8,7 @@ module HelperMethods
visit login_path
fill_in 'email', :with => user.email
fill_in 'password', :with => user.password || user.email.split('@').first
click_link_or_button 'Log in'
click_link_or_button 'Sign in'
end
def authenticate_api(user)

@ -4,7 +4,7 @@ module NavigationHelpers
end
def login_path
"/login"
"#{CartoDB.hostname}/login"
end
def logout_path
@ -48,11 +48,11 @@ module NavigationHelpers
end
def api_table_columns_url(table_identifier)
"#{api_url_prefix}/tables/#{table_identifier}/columns"
api_req "#{api_url_prefix}/tables/#{table_identifier}/columns"
end
def api_table_column_url(table_identifier, column_name)
"#{api_url_prefix}/tables/#{table_identifier}/columns/#{column_name}"
api_req "#{api_url_prefix}/tables/#{table_identifier}/columns/#{column_name}"
end
def api_table_record_column_url(table_identifier, row_identifier, column_name)
@ -84,6 +84,14 @@ module NavigationHelpers
def api_url_prefix
"#{CartoDB.hostname}/api/#{CartoDB::API::VERSION_1}"
end
def api_key
"api_key=#{$users_metadata.HMGET("rails:users:test", 'map_key').first}"
end
def api_req url
"#{url}?#{api_key}"
end
end

Loading…
Cancel
Save