ateam-merb-auth-old 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/LICENSE +44 -0
  2. data/README +212 -0
  3. data/Rakefile +50 -0
  4. data/TODO +14 -0
  5. data/activerecord_generators/ma_migration/ma_migration_generator.rb +41 -0
  6. data/activerecord_generators/ma_migration/templates/schema/migrations/%time_stamp%_add_ma_user.rb +21 -0
  7. data/app/controllers/application.rb +7 -0
  8. data/app/controllers/sessions.rb +3 -0
  9. data/app/controllers/users.rb +3 -0
  10. data/app/helpers/application_helper.rb +64 -0
  11. data/app/mailers/user_mailer.rb +24 -0
  12. data/app/mailers/views/user_mailer/activation.text.erb +1 -0
  13. data/app/mailers/views/user_mailer/forgot_password.text.erb +5 -0
  14. data/app/mailers/views/user_mailer/signup.text.erb +7 -0
  15. data/app/views/layout/merb_auth.html.erb +16 -0
  16. data/app/views/sessions/new.html.erb +13 -0
  17. data/app/views/users/new.html.erb +21 -0
  18. data/datamapper_generators/ma_migration/ma_migration_generator.rb +38 -0
  19. data/datamapper_generators/ma_migration/templates/schema/migrations/add_ma_user.rb +21 -0
  20. data/lib/ateam-merb-auth-old.rb +1 -0
  21. data/lib/merb-auth.rb +184 -0
  22. data/lib/merb-auth/adapters/activerecord/init.rb +26 -0
  23. data/lib/merb-auth/adapters/activerecord/map.rb +44 -0
  24. data/lib/merb-auth/adapters/activerecord/model.rb +81 -0
  25. data/lib/merb-auth/adapters/common.rb +161 -0
  26. data/lib/merb-auth/adapters/datamapper/init.rb +28 -0
  27. data/lib/merb-auth/adapters/datamapper/map.rb +35 -0
  28. data/lib/merb-auth/adapters/datamapper/model.rb +72 -0
  29. data/lib/merb-auth/adapters/map.rb +0 -0
  30. data/lib/merb-auth/adapters/sequel/init.rb +26 -0
  31. data/lib/merb-auth/adapters/sequel/map.rb +36 -0
  32. data/lib/merb-auth/adapters/sequel/model.rb +86 -0
  33. data/lib/merb-auth/controller/controller.rb +113 -0
  34. data/lib/merb-auth/controller/sessions_base.rb +41 -0
  35. data/lib/merb-auth/controller/users_base.rb +58 -0
  36. data/lib/merb-auth/initializer.rb +47 -0
  37. data/lib/merb-auth/merbtasks.rb +168 -0
  38. data/lib/merb-auth/slicetasks.rb +102 -0
  39. data/plugins/forgotten_password/app/controllers/passwords.rb +90 -0
  40. data/plugins/forgotten_password/app/models/user.rb +52 -0
  41. data/plugins/forgotten_password/app/views/passwords/edit.html.erb +9 -0
  42. data/plugins/forgotten_password/app/views/passwords/new.html.erb +4 -0
  43. data/plugins/forgotten_password/forgotten_password.rb +6 -0
  44. data/plugins/forgotten_password/init.rb +8 -0
  45. data/plugins/forgotten_password/spec/controller_spec.rb +236 -0
  46. data/plugins/forgotten_password/spec/model_spec.rb +52 -0
  47. data/plugins/forgotten_password/spec/spec_helper.rb +36 -0
  48. data/public/javascripts/master.js +0 -0
  49. data/public/stylesheets/master.css +2 -0
  50. data/spec/controllers/plugins/test_plugin.rb +17 -0
  51. data/spec/controllers/sessions_spec.rb +118 -0
  52. data/spec/controllers/users_spec.rb +119 -0
  53. data/spec/mailers/user_mailer_spec.rb +75 -0
  54. data/spec/merb_auth_spec.rb +231 -0
  55. data/spec/models/ar_model_spec.rb +50 -0
  56. data/spec/models/common_spec.rb +0 -0
  57. data/spec/models/model_spec.rb +23 -0
  58. data/spec/models/sq_model_spec.rb +50 -0
  59. data/spec/shared_specs/shared_model_spec.rb +445 -0
  60. data/spec/spec_helper.rb +114 -0
  61. data/spec/spec_helpers/helpers.rb +18 -0
  62. data/spec/spec_helpers/valid_model_hashes.rb +10 -0
  63. data/stubs/app/controllers/application.rb +2 -0
  64. data/stubs/app/controllers/main.rb +2 -0
  65. data/stubs/app/mailers/views/activation.text.erb +1 -0
  66. data/stubs/app/mailers/views/signup.text.erb +7 -0
  67. data/stubs/app/views/sessions/new.html.erb +14 -0
  68. data/stubs/app/views/users/new.html.erb +18 -0
  69. metadata +120 -0
@@ -0,0 +1,114 @@
1
+ require 'rubygems'
2
+ require 'merb-core'
3
+ require 'spec'
4
+ require 'merb-slices'
5
+ require 'merb-mailer'
6
+
7
+
8
+ # class Merb::BootLoader::SlicesForSpecs < Merb::BootLoader
9
+ #
10
+ # before Merb::BootLoader::BeforeAppLoads
11
+ #
12
+ # def self.run
13
+ # Merb::Config.use do |c|
14
+ # c[:session_store] = "memory"
15
+ # end
16
+ # Merb::Slices.register_and_load(File.join(File.dirname(__FILE__), '..', 'lib', 'merb-auth.rb'))
17
+ # end
18
+ #
19
+ # end
20
+
21
+ Merb::Plugins.config[:merb_slices][:auto_register] = true
22
+ Merb::Plugins.config[:merb_slices][:search_path] = File.join(File.dirname(__FILE__), '..', 'lib', 'merb-auth.rb')
23
+
24
+ module Merb
25
+ def self.orm_generator_scope
26
+ :datamapper
27
+ end
28
+ end
29
+
30
+ # Using Merb.root below makes sure that the correct root is set for
31
+ # - testing standalone, without being installed as a gem and no host application
32
+ # - testing from within the host application; its root will be used
33
+ Merb.start_environment(
34
+ :testing => true,
35
+ :adapter => 'runner',
36
+ :environment => ENV['MERB_ENV'] || 'test',
37
+ :merb_root => Merb.root,
38
+ :session_store => 'memory'
39
+ )
40
+
41
+
42
+ class Merb::Mailer
43
+ self.delivery_method = :test_send
44
+ end
45
+
46
+ path = File.dirname(__FILE__)
47
+ # Load up all the shared specs
48
+ Dir[path / "shared_specs" / "**" / "*_spec.rb"].each do |f|
49
+ require f
50
+ end
51
+
52
+ # Load up all the spec helpers
53
+ Dir[path / "spec_helpers" / "**" / "*.rb"].each do |f|
54
+ require f
55
+ end
56
+
57
+ module Merb
58
+ module Test
59
+ module SliceHelper
60
+
61
+ # The absolute path to the current slice
62
+ def current_slice_root
63
+ @current_slice_root ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
64
+ end
65
+
66
+ # Whether the specs are being run from a host application or standalone
67
+ def standalone?
68
+ not $SLICED_APP
69
+ end
70
+
71
+ end
72
+ end
73
+ end
74
+
75
+ Spec::Runner.configure do |config|
76
+ config.include(Merb::Test::ViewHelper)
77
+ config.include(Merb::Test::RouteHelper)
78
+ config.include(Merb::Test::ControllerHelper)
79
+ config.include(Merb::Test::SliceHelper)
80
+ config.include(ValidModelHashes)
81
+ config.before(:each) do
82
+ Merb::Router.prepare { |r| r.add_slice(:MerbAuth) } if standalone?
83
+ end
84
+ end
85
+
86
+
87
+ # GLobal helpers for merb-auth
88
+ def reload_ma!(create_class = nil)
89
+ Object.class_eval do
90
+ remove_const("User") if defined?(User)
91
+ remove_const("MA") if defined?(MA)
92
+ remove_const("MerbAuth")
93
+ end
94
+ load File.join(File.dirname(__FILE__), "..", "lib", "merb-auth.rb")
95
+ register_datamapper!
96
+ stub_orm_scope
97
+
98
+ MA.load_slice
99
+ yield if block_given?
100
+ MA[:user] = nil
101
+ ::DataMapper::Resource.descendants.delete(User) if defined?(User)
102
+ MA.loaded
103
+ unless create_class.nil?
104
+ Object.class_eval <<-EOS
105
+ class #{create_class}
106
+ include DataMapper::Resource
107
+ include MerbAuth::Adapter::DataMapper
108
+ include MerbAuth::Adapter::DataMapper::DefaultModelSetup
109
+ end
110
+ EOS
111
+ end
112
+ Merb::BootLoader::MaLoadPlugins.run
113
+ MA.activate
114
+ end
@@ -0,0 +1,18 @@
1
+ class String
2
+ def self.random(length = 10)
3
+ @__avail_chars ||= (('a'..'z').to_a << ("A".."Z").to_a).flatten
4
+ (1..length).inject(""){|out, index| out << @__avail_chars[rand(@__avail_chars.size)]}
5
+ end
6
+ end
7
+
8
+ class Hash
9
+
10
+ def with( opts )
11
+ self.merge(opts)
12
+ end
13
+
14
+ def without(*args)
15
+ self.dup.delete_if{ |k,v| args.include?(k)}
16
+ end
17
+
18
+ end
@@ -0,0 +1,10 @@
1
+ module ValidModelHashes
2
+ def valid_user_hash
3
+ { :login => String.random(10),
4
+ :email => "#{String.random}@example.com",
5
+ :password => "sekret",
6
+ :password_confirmation => "sekret"
7
+ }
8
+ end
9
+ end
10
+
@@ -0,0 +1,2 @@
1
+ class MerbAuth::Application < Merb::Controller
2
+ end
@@ -0,0 +1,2 @@
1
+ class MerbAuth::Main < MerbAuth::Application
2
+ end
@@ -0,0 +1 @@
1
+ Your email has been authenticated <%= @user.email %>
@@ -0,0 +1,7 @@
1
+ Your account has been created.
2
+
3
+ Username: <%= @ivar.email %>
4
+
5
+ Visit this url to activate your account:
6
+
7
+ <%= url(:merb_auth_user_activation, :activation_code => @ivar.activation_code) %>
@@ -0,0 +1,14 @@
1
+ <% form_tag :action => url(:merb_auth_login) do -%>
2
+ <p><label for="email">Email</label><br/>
3
+ <%= text_field :name => "email" %></p>
4
+
5
+ <p><label for="password">Password</label><br/>
6
+ <%= password_field :name => "password" %></p>
7
+
8
+ <!-- Uncomment this if you want this functionality
9
+ <p><label for="remember_me">Remember me:</label>
10
+ <%= check_box :name => 'remember_me' %></p>
11
+ -->
12
+
13
+ <p><%= submit_button 'Log in' %></p>
14
+ <% end -%>
@@ -0,0 +1,18 @@
1
+ <%= error_messages_for @ivar %>
2
+ <% form_for @ivar, :action => url(:merb_auth_users) do %>
3
+ <p>
4
+ <%= text_control :email, :label => "Email" %>
5
+ </p>
6
+ <p>
7
+ <%= text_control :login, :label => "Nickname" %>
8
+ </p>
9
+ <p>
10
+ <%= password_control :password, :label => "Password" %>
11
+ </p>
12
+ <p>
13
+ <%= password_control :password_confirmation, :label => "Password Confirmation" %>
14
+ </p>
15
+ <p>
16
+ <%= submit_button "Sign up" %>
17
+ </p>
18
+ <% end %>
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ateam-merb-auth-old
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ateam
8
+ autorequire: name
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-11 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: ateam.web@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ files:
25
+ - app/views/users/new.html.erb
26
+ - app/views/layout/merb_auth.html.erb
27
+ - app/views/sessions/new.html.erb
28
+ - app/mailers/views/user_mailer/activation.text.erb
29
+ - app/mailers/views/user_mailer/signup.text.erb
30
+ - app/mailers/views/user_mailer/forgot_password.text.erb
31
+ - app/mailers/user_mailer.rb
32
+ - app/controllers/sessions.rb
33
+ - app/controllers/users.rb
34
+ - app/controllers/application.rb
35
+ - app/helpers/application_helper.rb
36
+ - lib/merb-auth/initializer.rb
37
+ - lib/merb-auth/slicetasks.rb
38
+ - lib/merb-auth/adapters/activerecord/model.rb
39
+ - lib/merb-auth/adapters/activerecord/map.rb
40
+ - lib/merb-auth/adapters/activerecord/init.rb
41
+ - lib/merb-auth/adapters/common.rb
42
+ - lib/merb-auth/adapters/map.rb
43
+ - lib/merb-auth/adapters/sequel/model.rb
44
+ - lib/merb-auth/adapters/sequel/map.rb
45
+ - lib/merb-auth/adapters/sequel/init.rb
46
+ - lib/merb-auth/adapters/datamapper/model.rb
47
+ - lib/merb-auth/adapters/datamapper/map.rb
48
+ - lib/merb-auth/adapters/datamapper/init.rb
49
+ - lib/merb-auth/controller/users_base.rb
50
+ - lib/merb-auth/controller/sessions_base.rb
51
+ - lib/merb-auth/controller/controller.rb
52
+ - lib/merb-auth/merbtasks.rb
53
+ - lib/merb-auth.rb
54
+ - lib/ateam-merb-auth-old.rb
55
+ - TODO
56
+ - spec/spec_helpers/valid_model_hashes.rb
57
+ - spec/spec_helpers/helpers.rb
58
+ - spec/spec_helper.rb
59
+ - spec/mailers/user_mailer_spec.rb
60
+ - spec/controllers/users_spec.rb
61
+ - spec/controllers/plugins/test_plugin.rb
62
+ - spec/controllers/sessions_spec.rb
63
+ - spec/models/sq_model_spec.rb
64
+ - spec/models/ar_model_spec.rb
65
+ - spec/models/common_spec.rb
66
+ - spec/models/model_spec.rb
67
+ - spec/merb_auth_spec.rb
68
+ - spec/shared_specs/shared_model_spec.rb
69
+ - LICENSE
70
+ - Rakefile
71
+ - stubs/app/views/users/new.html.erb
72
+ - stubs/app/views/sessions/new.html.erb
73
+ - stubs/app/mailers/views/activation.text.erb
74
+ - stubs/app/mailers/views/signup.text.erb
75
+ - stubs/app/controllers/main.rb
76
+ - stubs/app/controllers/application.rb
77
+ - README
78
+ - datamapper_generators/ma_migration/ma_migration_generator.rb
79
+ - datamapper_generators/ma_migration/templates/schema/migrations/add_ma_user.rb
80
+ - public/stylesheets/master.css
81
+ - public/javascripts/master.js
82
+ - activerecord_generators/ma_migration/ma_migration_generator.rb
83
+ - activerecord_generators/ma_migration/templates/schema/migrations/%time_stamp%_add_ma_user.rb
84
+ - plugins/forgotten_password/app/views/passwords/edit.html.erb
85
+ - plugins/forgotten_password/app/views/passwords/new.html.erb
86
+ - plugins/forgotten_password/app/controllers/passwords.rb
87
+ - plugins/forgotten_password/app/models/user.rb
88
+ - plugins/forgotten_password/spec/controller_spec.rb
89
+ - plugins/forgotten_password/spec/spec_helper.rb
90
+ - plugins/forgotten_password/spec/model_spec.rb
91
+ - plugins/forgotten_password/forgotten_password.rb
92
+ - plugins/forgotten_password/init.rb
93
+ has_rdoc: true
94
+ homepage: http://a-team.lt
95
+ post_install_message:
96
+ rdoc_options: []
97
+
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: "0"
105
+ version:
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: "0"
111
+ version:
112
+ requirements: []
113
+
114
+ rubyforge_project:
115
+ rubygems_version: 1.2.0
116
+ signing_key:
117
+ specification_version: 2
118
+ summary: Merb authentication gem
119
+ test_files: []
120
+