Permalink
Browse files

adding in extra tests

  • Loading branch information...
1 parent 2d5106d commit 0bf374287f0f8b2c0737cdefb991df78d38a7072 @pbrumm committed Apr 10, 2011
View
@@ -2,6 +2,7 @@
require 'sinatra'
require 'haml'
require 'dm-core'
+require 'dm-migrations'
require 'rack-flash'
require File.join(File.dirname(__FILE__), '../../lib/sinatra-authentication')
@@ -2,6 +2,7 @@
require 'sinatra'
require 'haml'
require 'dm-core'
+require 'dm-migrations'
require 'rack-flash'
require File.join(File.dirname(__FILE__), '../../lib/sinatra-authentication')
View
@@ -0,0 +1,55 @@
+require 'rubygems'
+require 'sinatra'
+require 'haml'
+require 'sinbook'
+require 'dm-core'
+require File.join(File.dirname(__FILE__), '../../lib/sinatra-authentication')
+
+facebook do
+ api_key 'aa2db1b96cb7b57f0c5b1d4d3d8f0a22'
+ secret '21d94ee63969ae3b3f833689838ca00f'
+ app_id 48652736613
+ url 'peoplewithjetpacks.com:4568/'
+ callback 'peoplewithjetpacks.com:4568/'
+end
+
+set :port, 4568
+
+DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/test.db")
+DataMapper.auto_migrate!
+
+use Rack::Session::Cookie, :secret => "heyhihello"
+
+set :environment, 'development'
+set :public, 'public'
+set :views, 'views'
+
+get '/' do
+ haml :main
+end
+
+get '/test' do
+ login_required
+ 'hihihi'
+end
+
+__END__
+
+@@ layout
+%html{:xmlns=>"http://www.w3.org/1999/xhtml", :'xmlns:fb'=>"http://www.facebook.com/2008/fbml"}
+ %head
+ %title Welcome to my Facebook Connect website!
+ %script{:type => 'text/javascript', :src => 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US'}
+ %body
+ = render_login_logout
+ = yield
+ :javascript
+ FB.init("#{fb.api_key}", "/receiver")
+
+@@ main
+- if fb[:user]
+ Hi,
+ %fb:profile-pic{:uid => fb[:user]}
+ %fb:name{:uid => fb[:user], :useyou => 'false', :firstnameonly => 'true'}
+ !
+
@@ -18,6 +18,10 @@
%input{ :id => "user_email", :name => "user[email]", :size => 30, :type => "text", :value => @user.email }
.field
.label
+ %label{:for => "user_email"} Name
+ %input{ :id => "user_email", :name => "user[name]", :size => 30, :type => "text", :value => @user.name }
+ .field
+ .label
%label{:for => "user_password"} New password
%input{ :id => "user_password", :name => "user[password]", :size => 30, :type => "password" }
.field
@@ -8,14 +8,14 @@
%input{ :id => "user_email", :name => "user[email]", :size => 30, :type => "text" }
.field
.label
- %label{:for => "user_password"} Password
- %input{ :id => "user_password", :name => "user[password]", :size => 30, :type => "password" }
- .field
- .label
%label{:for => "user_name"} Name
%input{ :id => "user_name", :name => "user[name]", :size => 30, :type => "text" }
.field
.label
+ %label{:for => "user_password"} Password
+ %input{ :id => "user_password", :name => "user[password]", :size => 30, :type => "password" }
+ .field
+ .label
%label{:for => "user_password_confirmation"} Confirm Password
%input{ :id => "user_password_confirmation", :name => "user[password_confirmation]", :size => 30, :type => "password" }
.buttons
View
@@ -2,6 +2,10 @@ class TestHelper
def self.gen_user
{'user[email]' => 'yodawg@gmail.com', 'user[password]' => 'password', 'user[password_confirmation]' => 'password'}
end
+
+ def self.gen_user_for_model
+ {:email => 'yodawg@gmail.com', :password => 'password', :password_confirmation => 'password'}
+ end
end
def app
View
@@ -0,0 +1,25 @@
+require 'rubygems'
+require 'sinatra'
+require 'haml'
+require 'rack-flash'
+require 'mongo_mapper'
+
+#logger = Logger.new($stdout)
+#MongoMapper.connection = Mongo::Connection.new('db.mongohq.com', 27017, :logger => logger)
+#MongoMapper.database = "fdbk"
+#MongoMapper.database.authenticate(ENV['mongohq_user'], ENV['mongohq_pass'])
+
+require File.join(File.dirname(__FILE__), '../../lib/sinatra-authentication')
+
+MongoMapper.database = "sinatraauthtest"
+
+use Rack::Session::Cookie, :secret => "heyhihello"
+use Rack::Flash
+
+set :environment, 'development'
+set :public, 'public'
+set :views, 'views'
+
+get '/' do
+ haml "= render_login_logout", :layout => :layout
+end
View
@@ -0,0 +1,29 @@
+require 'rubygems'
+require 'sinatra'
+require 'haml'
+require 'rack-flash'
+require 'mongoid'
+
+#logger = Logger.new($stdout)
+#MongoMapper.connection = Mongo::Connection.new('db.mongohq.com', 27017, :logger => logger)
+#MongoMapper.database = "fdbk"
+#MongoMapper.database.authenticate(ENV['mongohq_user'], ENV['mongohq_pass'])
+
+require File.join(File.dirname(__FILE__), '../../lib/sinatra-authentication')
+
+Mongoid.configure do |config|
+ name = "sinatraauth_test"
+ host = "localhost"
+ config.master = Mongo::Connection.new.db(name)
+end
+
+use Rack::Session::Cookie, :secret => "heyhihello"
+use Rack::Flash
+
+set :environment, 'development'
+set :public, 'public'
+set :views, 'views'
+
+get '/' do
+ haml "= render_login_logout", :layout => :layout
+end
View
@@ -0,0 +1,18 @@
+require 'rubygems'
+require 'sinatra'
+require 'haml'
+require 'rufus/tokyo'
+require 'rack-flash'
+require File.join(File.dirname(__FILE__), '../../lib/sinatra-authentication')
+
+use Rack::Session::Cookie, :secret => "heyhihello"
+use Rack::Flash
+TcUserTable.cabinet_path = File.dirname(__FILE__)
+
+set :environment, 'development'
+set :public, 'public'
+set :views, 'views'
+
+get '/' do
+ haml "= render_login_logout", :layout => :layout
+end
View
@@ -0,0 +1,62 @@
+require 'rubygems'
+require 'haml'
+require 'sinbook'
+require 'rufus/tokyo'
+require 'sinatra'
+require File.join(File.dirname(__FILE__), '../../lib/sinatra-authentication')
+
+use Rack::Session::Cookie, :secret => "heyhihello"
+TcUserTable.cabinet_path = File.dirname(__FILE__)
+
+facebook do
+ api_key 'aa2db1b96cb7b57f0c5b1d4d3d8f0a22'
+ secret '21d94ee63969ae3b3f833689838ca00f'
+ app_id 48652736613
+ url 'peoplewithjetpacks.com:4568/'
+ callback 'peoplewithjetpacks.com:4568/'
+end
+
+set :port, 4568
+
+get '/' do
+ haml :main
+end
+
+get '/test' do
+ login_required
+ 'hihihi'
+end
+
+__END__
+
+@@ layout
+%html{:xmlns=>"http://www.w3.org/1999/xhtml", :'xmlns:fb'=>"http://www.facebook.com/2008/fbml"}
+ %head
+ %title Welcome to my Facebook Connect website!
+ %script{:type => 'text/javascript', :src => 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US'}
+ %script{:type => 'text/javascript', :src => 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'}
+ :javascript
+ $(document).ready(function(){
+ /* test facebook crap works with ajax */
+ $('.sinatra-authentication-login').click(function(){
+ $.get($(this).attr('href'), {}, function(data){
+ $('#test_box').html(data);
+ });
+ return false;
+ });
+ });
+ %body
+ = render_login_logout
+ = yield
+ :javascript
+ FB.init("#{fb.api_key}", "/receiver")
+ #test_box
+
+@@ main
+- if fb[:user]
+ Hi,
+ %fb:profile-pic{:uid => fb[:user]}
+ %fb:name{:uid => fb[:user], :useyou => 'false', :firstnameonly => 'true'}
+ !
+ %br/
+
View
@@ -0,0 +1,5 @@
+require 'lib/mongoid_app'
+require 'lib/helper'
+require 'test/unit'
+require 'rack/test'
+require 'route_tests'
View
@@ -0,0 +1,40 @@
+require 'lib/mm_app'
+require 'lib/helper'
+require 'test/unit'
+require 'rack/test'
+require 'route_tests'
+
+#Test::Unit::TestCase.send :include, Rack::Test::Methods
+
+#class SinatraAuthMongoMapperTest < Test::Unit::TestCase
+# include Rack::Test::Methods
+#
+# def app
+# TestApp
+# end
+#
+# def setup
+# post '/signup', TestHelper.gen_user
+# follow_redirect!
+# get '/logout'
+ # end
+#
+# def test_should_login
+# post '/login', {'email' => TestHelper.gen_user['user[email]'], 'password' => TestHelper.gen_user['user[password]']}
+# follow_redirect!
+#
+# assert_equal 'http://example.org/', last_request.url
+# #assert cookie_jar['user']
+# assert last_request.env['rack.session'][:user]
+# assert last_response.ok?
+# end
+#
+# def test_should_logout
+# post '/login', {'email' => TestHelper.gen_user['user[email]'], 'password' => TestHelper.gen_user['user[password]']}
+# get '/logout'
+# follow_redirect!
+#
+# assert !last_request.env['rack.session'][:user]
+# assert_equal 'http://example.org/', last_request.url
+# end
+#end
View
@@ -0,0 +1,5 @@
+require 'lib/tc_app'
+require 'lib/helper'
+require 'test/unit'
+require 'rack/test'
+require 'route_tests'

0 comments on commit 0bf3742

Please sign in to comment.