filiptepper-oauth-plugin 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/.gitignore +5 -0
  2. data/CHANGELOG +101 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +376 -0
  5. data/Rakefile +38 -0
  6. data/VERSION +1 -0
  7. data/generators/oauth_consumer/USAGE +10 -0
  8. data/generators/oauth_consumer/oauth_consumer_generator.rb +50 -0
  9. data/generators/oauth_consumer/templates/consumer_token.rb +5 -0
  10. data/generators/oauth_consumer/templates/controller.rb +19 -0
  11. data/generators/oauth_consumer/templates/index.html.erb +29 -0
  12. data/generators/oauth_consumer/templates/index.html.haml +18 -0
  13. data/generators/oauth_consumer/templates/migration.rb +20 -0
  14. data/generators/oauth_consumer/templates/oauth_config.rb +41 -0
  15. data/generators/oauth_consumer/templates/show.html.erb +7 -0
  16. data/generators/oauth_consumer/templates/show.html.haml +8 -0
  17. data/generators/oauth_provider/USAGE +20 -0
  18. data/generators/oauth_provider/lib/insert_routes.rb +67 -0
  19. data/generators/oauth_provider/oauth_provider_generator.rb +125 -0
  20. data/generators/oauth_provider/templates/_form.html.erb +17 -0
  21. data/generators/oauth_provider/templates/_form.html.haml +21 -0
  22. data/generators/oauth_provider/templates/access_token.rb +16 -0
  23. data/generators/oauth_provider/templates/authorize.html.erb +14 -0
  24. data/generators/oauth_provider/templates/authorize.html.haml +16 -0
  25. data/generators/oauth_provider/templates/authorize_failure.html.erb +1 -0
  26. data/generators/oauth_provider/templates/authorize_failure.html.haml +1 -0
  27. data/generators/oauth_provider/templates/authorize_success.html.erb +1 -0
  28. data/generators/oauth_provider/templates/authorize_success.html.haml +1 -0
  29. data/generators/oauth_provider/templates/client_application.rb +55 -0
  30. data/generators/oauth_provider/templates/client_application_spec.rb +29 -0
  31. data/generators/oauth_provider/templates/client_application_test.rb +42 -0
  32. data/generators/oauth_provider/templates/client_applications.yml +23 -0
  33. data/generators/oauth_provider/templates/clients_controller.rb +52 -0
  34. data/generators/oauth_provider/templates/clients_controller_spec.rb +239 -0
  35. data/generators/oauth_provider/templates/clients_controller_test.rb +280 -0
  36. data/generators/oauth_provider/templates/controller.rb +11 -0
  37. data/generators/oauth_provider/templates/controller_spec.rb +367 -0
  38. data/generators/oauth_provider/templates/controller_spec_helper.rb +80 -0
  39. data/generators/oauth_provider/templates/controller_test.rb +310 -0
  40. data/generators/oauth_provider/templates/controller_test_helper.rb +115 -0
  41. data/generators/oauth_provider/templates/edit.html.erb +7 -0
  42. data/generators/oauth_provider/templates/edit.html.haml +4 -0
  43. data/generators/oauth_provider/templates/index.html.erb +43 -0
  44. data/generators/oauth_provider/templates/index.html.haml +39 -0
  45. data/generators/oauth_provider/templates/migration.rb +46 -0
  46. data/generators/oauth_provider/templates/new.html.erb +5 -0
  47. data/generators/oauth_provider/templates/new.html.haml +5 -0
  48. data/generators/oauth_provider/templates/oauth_nonce.rb +13 -0
  49. data/generators/oauth_provider/templates/oauth_nonce_spec.rb +24 -0
  50. data/generators/oauth_provider/templates/oauth_nonce_test.rb +26 -0
  51. data/generators/oauth_provider/templates/oauth_nonces.yml +13 -0
  52. data/generators/oauth_provider/templates/oauth_token.rb +31 -0
  53. data/generators/oauth_provider/templates/oauth_token_spec.rb +309 -0
  54. data/generators/oauth_provider/templates/oauth_token_test.rb +57 -0
  55. data/generators/oauth_provider/templates/oauth_tokens.yml +17 -0
  56. data/generators/oauth_provider/templates/request_token.rb +40 -0
  57. data/generators/oauth_provider/templates/show.html.erb +27 -0
  58. data/generators/oauth_provider/templates/show.html.haml +30 -0
  59. data/init.rb +1 -0
  60. data/install.rb +2 -0
  61. data/lib/oauth-plugin.rb +1 -0
  62. data/lib/oauth/controllers/application_controller_methods.rb +110 -0
  63. data/lib/oauth/controllers/consumer_controller.rb +76 -0
  64. data/lib/oauth/controllers/provider_controller.rb +111 -0
  65. data/lib/oauth/models/consumers/service_loader.rb +18 -0
  66. data/lib/oauth/models/consumers/services/agree2_token.rb +15 -0
  67. data/lib/oauth/models/consumers/services/fireeagle_token.rb +39 -0
  68. data/lib/oauth/models/consumers/services/twitter_token.rb +18 -0
  69. data/lib/oauth/models/consumers/token.rb +60 -0
  70. data/oauth-plugin.gemspec +112 -0
  71. data/rails/init.rb +7 -0
  72. data/tasks/oauth_tasks.rake +4 -0
  73. data/uninstall.rb +1 -0
  74. metadata +136 -0
@@ -0,0 +1,38 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the oauth plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for the oauth plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'Oauth'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ begin
25
+ require 'jeweler'
26
+ Jeweler::Tasks.new do |gemspec|
27
+ gemspec.name = "oauth-plugin"
28
+ gemspec.summary = "Ruby on Rails Plugin for OAuth Provider and Consumer"
29
+ gemspec.description = "Rails plugin for implementing an OAuth Provider or Consumer"
30
+ gemspec.email = "oauth-ruby@googlegroups.com"
31
+ gemspec.homepage = "http://github.com/pelle/oauth-plugin/tree/master"
32
+ gemspec.authors = ["Pelle Braendgaard"]
33
+ gemspec.add_dependency('oauth', '>= 0.3.5')
34
+ gemspec.rubyforge_project = 'oauth'
35
+ end
36
+ rescue LoadError
37
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
38
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.10
@@ -0,0 +1,10 @@
1
+ ./script/generate oauth_consumer
2
+
3
+ This creates an OAuth Provider controller as well as requisite models.
4
+
5
+ It requires an authentication framework such as acts_as_authenticated, restful_authentication or restful_open_id_authentication that provides the methods "login_required" and "current_user".
6
+
7
+ If you generated the migration file (true by default), make sure you run
8
+ rake db:migrate
9
+
10
+ See README.rdoc for more.
@@ -0,0 +1,50 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../oauth_provider/lib/insert_routes.rb")
2
+
3
+ class OauthConsumerGenerator < Rails::Generator::Base
4
+ default_options :skip_migration => false
5
+
6
+ def manifest
7
+ record do |m|
8
+
9
+ # Controller, helper, views, and test directories.
10
+ m.directory File.join('app/models')
11
+ m.directory File.join('app/controllers')
12
+ m.directory File.join('app/helpers')
13
+ m.directory File.join('app/views', 'oauth_consumers')
14
+ m.directory File.join('config/initializers')
15
+
16
+ m.template 'oauth_config.rb',File.join('config/initializers', "oauth_consumers.rb")
17
+ m.template 'consumer_token.rb',File.join('app/models',"consumer_token.rb")
18
+
19
+ m.template 'controller.rb',File.join('app/controllers',"oauth_consumers_controller.rb")
20
+ m.route_entry "map.resources :oauth_consumers,:member=>{:callback=>:get}"
21
+
22
+ @template_extension= options[:haml] ? "haml" : "erb"
23
+
24
+ m.template "show.html.#{@template_extension}", File.join('app/views', 'oauth_consumers', "show.html.#{@template_extension}")
25
+ m.template "index.html.#{@template_extension}", File.join('app/views', 'oauth_consumers', "index.html.#{@template_extension}")
26
+
27
+ unless options[:skip_migration]
28
+ m.migration_template 'migration.rb', 'db/migrate', :assigns => {
29
+ :migration_name => "CreateOauthConsumerTokens"
30
+ }, :migration_file_name => "create_oauth_consumer_tokens"
31
+ end
32
+ end
33
+ end
34
+
35
+ protected
36
+ def banner
37
+ "Usage: #{$0} #{spec.name}"
38
+ end
39
+
40
+ def add_options!(opt)
41
+ opt.separator ''
42
+ opt.separator 'Options:'
43
+ opt.on("--skip-migration",
44
+ "Don't generate a migration file") { |v| options[:skip_migration] = v }
45
+ # opt.on("--test-unit",
46
+ # "Generate the Test::Unit compatible tests instead of RSpec") { |v| options[:test_unit] = v }
47
+ opt.on("--haml",
48
+ "Templates use haml") { |v| options[:haml] = v }
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ require 'oauth/models/consumers/token'
2
+ class ConsumerToken < ActiveRecord::Base
3
+ include Oauth::Models::Consumers::Token
4
+
5
+ end
@@ -0,0 +1,19 @@
1
+ require 'oauth/controllers/consumer_controller'
2
+ class OauthConsumersController < ApplicationController
3
+ include Oauth::Controllers::ConsumerController
4
+
5
+ def index
6
+ @consumer_tokens=ConsumerToken.all :conditions=>{:user_id=>current_user.id}
7
+ @services=OAUTH_CREDENTIALS.keys-@consumer_tokens.collect{|c| c.class.service_name}
8
+ end
9
+
10
+ protected
11
+
12
+ # Change this to decide where you want to redirect user to after callback is finished.
13
+ # params[:id] holds the service name so you could use this to redirect to various parts
14
+ # of your application depending on what service you're connecting to.
15
+ def go_back
16
+ redirect_to root_url
17
+ end
18
+
19
+ end
@@ -0,0 +1,29 @@
1
+ <h1>Services</h1>
2
+
3
+ <%% if @consumer_tokens.empty? %>
4
+ <p>
5
+ You are currently not connected to any external services.
6
+ </p>
7
+ <%% else %>
8
+ <p>
9
+ You are connected to the following services:
10
+ </p>
11
+ <ul>
12
+ <%% @consumer_tokens.each do |token| %>
13
+ <li>
14
+ <%%= link_to token.class.service_name.to_s.humanize, oauth_consumer_path(token.class.service_name) %>
15
+ </li>
16
+ <%% end %>
17
+ </ul>
18
+ <%% end %>
19
+
20
+ <%% unless @services.empty? %>
21
+ <h3>You can connect to the following services:</h3>
22
+ <ul>
23
+ <%% @services.each do |service| %>
24
+ <li>
25
+ <%%= link_to service.to_s.humanize, oauth_consumer_path(service) %>
26
+ </li>
27
+ <%% end %>
28
+ </ul>
29
+ <%% end %>
@@ -0,0 +1,18 @@
1
+ %h1 Services
2
+
3
+ -if @consumer_tokens.empty?
4
+ %p
5
+ You are currently not connected to any external services.
6
+ -else
7
+ %p You are connected to the following services:
8
+ %ul
9
+ -@consumer_tokens.each do |token|
10
+ %li
11
+ =link_to token.class.service_name.to_s.humanize, oauth_consumer_path(token.class.service_name)
12
+
13
+ -unless @services.empty?
14
+ %h3 You can connect to the following services:
15
+ %ul
16
+ -@services.each do |service|
17
+ %li
18
+ =link_to service.to_s.humanize,oauth_consumer_path(service)
@@ -0,0 +1,20 @@
1
+ class CreateOauthConsumerTokens < ActiveRecord::Migration
2
+ def self.up
3
+
4
+ create_table :consumer_tokens do |t|
5
+ t.integer :user_id
6
+ t.string :type, :limit => 30
7
+ t.string :token
8
+ t.string :secret
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :consumer_tokens, :token, :unique
13
+
14
+ end
15
+
16
+ def self.down
17
+ drop_table :consumer_tokens
18
+ end
19
+
20
+ end
@@ -0,0 +1,41 @@
1
+ # edit this file to contain credentials for the OAuth services you support.
2
+ # each entry needs a corresponding token model.
3
+ #
4
+ # eg. :twitter => TwitterToken, :hour_feed => HourFeedToken etc.
5
+ #
6
+ # OAUTH_CREDENTIALS={
7
+ # :twitter=>{
8
+ # :key=>"",
9
+ # :secret=>""
10
+ # },
11
+ # :agree2=>{
12
+ # :key=>"",
13
+ # :secret=>""
14
+ # },
15
+ # :fireeagle=>{
16
+ # :key=>"",
17
+ # :secret=>""
18
+ # },
19
+ # :hour_feed=>{
20
+ # :key=>"",
21
+ # :secret=>"",
22
+ # :options=>{ # OAuth::Consumer options
23
+ # :site=>"http://hourfeed.com" # Remember to add a site for a generic OAuth site
24
+ # }
25
+ # },
26
+ # :nu_bux=>{
27
+ # :key=>"",
28
+ # :secret=>"",
29
+ # :super_class=>"OpenTransactToken", # if a OAuth service follows a particular standard
30
+ # # with a token implementation you can set the superclass
31
+ # # to use
32
+ # :options=>{ # OAuth::Consumer options
33
+ # :site=>"http://nubux.heroku.com"
34
+ # }
35
+ # }
36
+ # }
37
+ #
38
+ OAUTH_CREDENTIALS={
39
+ } unless defined? OAUTH_CREDENTIALS
40
+
41
+ load 'oauth/models/consumers/service_loader.rb'
@@ -0,0 +1,7 @@
1
+ <h1>You are already Connected to <%%=params[:id].humanize%></h1>
2
+ <%% form_tag oauth_consumer_path(params[:id]),:method=>:delete do %>
3
+ <%%=submit_tag "Disconnect" %>
4
+ or
5
+ <%%=submit_tag "Reconnect" %>
6
+ if you experienced a problem.
7
+ <%% end %>
@@ -0,0 +1,8 @@
1
+ %h1
2
+ You are already Connected to
3
+ =params[:id].humanize
4
+ -form_tag oauth_consumer_path(params[:id]),:method=>:delete do
5
+ =submit_tag "Disconnect"
6
+ or
7
+ =submit_tag "Reconnect"
8
+ if you experienced a problem.
@@ -0,0 +1,20 @@
1
+ ./script/generate oauth_provider
2
+
3
+ This creates an OAuth Provider controller as well as the requisite models.
4
+
5
+ It requires an authentication framework such as acts_as_authenticated, restful_authentication or restful_open_id_authentication.
6
+
7
+ If you generated the migration file (true by default), make sure you run
8
+
9
+ rake db:migrate
10
+
11
+ include the following in your user.rb
12
+
13
+ has_many :client_applications
14
+ has_many :tokens, :class_name=>"OauthToken",:order=>"authorized_at desc",:include=>[:client_application]
15
+
16
+ For legacy OAUTH 1.0 support add the following constant in your environment.rb
17
+
18
+ OAUTH_10_SUPPORT = true
19
+
20
+ Note, you should only do this if you really positively require to support old OAuth1.0 clients. There is a serious security issue with this.
@@ -0,0 +1,67 @@
1
+ # Stolen from http://github.com/technoweenie/restful-authentication
2
+
3
+ Rails::Generator::Commands::Create.class_eval do
4
+ def route_entry(raw)
5
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
6
+
7
+ logger.route raw
8
+ unless options[:pretend]
9
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
10
+ "#{match}\n #{raw}\n"
11
+ end
12
+ end
13
+ end
14
+
15
+ def route_resource(*resources)
16
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
17
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
18
+
19
+ logger.route "map.resource #{resource_list}"
20
+ unless options[:pretend]
21
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
22
+ "#{match}\n map.resource #{resource_list}\n"
23
+ end
24
+ end
25
+ end
26
+
27
+ def route_name(name, path, route_options = {})
28
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
29
+
30
+ logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
31
+ unless options[:pretend]
32
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
33
+ "#{match}\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ Rails::Generator::Commands::Destroy.class_eval do
40
+ def route_resource(*resources)
41
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
42
+ look_for = "\n map.resource #{resource_list}\n"
43
+ logger.route "map.resource #{resource_list}"
44
+ unless options[:pretend]
45
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
46
+ end
47
+ end
48
+
49
+ def route_name(name, path, route_options = {})
50
+ look_for = "\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
51
+ logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
52
+ unless options[:pretend]
53
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
54
+ end
55
+ end
56
+ end
57
+
58
+ Rails::Generator::Commands::List.class_eval do
59
+ def route_resource(*resources)
60
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
61
+ logger.route "map.resource #{resource_list}"
62
+ end
63
+
64
+ def route_name(name, path, options = {})
65
+ logger.route "map.#{name} '#{path}', :controller => '{options[:controller]}', :action => '#{options[:action]}'"
66
+ end
67
+ end
@@ -0,0 +1,125 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/lib/insert_routes.rb")
2
+ class OauthProviderGenerator < Rails::Generator::Base
3
+ default_options :skip_migration => false
4
+ attr_reader :class_path,
5
+ :controller_name,
6
+ :controller_class_path,
7
+ :controller_file_path,
8
+ :controller_class_name,
9
+ :controller_singular_name,
10
+ :controller_plural_name
11
+ alias_method :controller_file_name, :controller_singular_name
12
+
13
+ def initialize(runtime_args, runtime_options = {})
14
+ super
15
+
16
+ @controller_name = args.shift || 'oauth'
17
+ @controller_singular_name = 'oauth'
18
+ @controller_plural_name = 'oauth'
19
+ @controller_file_name = 'oauth'
20
+ @controller_class_name="Oauth"
21
+ @class_path=''
22
+ @controller_class_path=''
23
+ end
24
+
25
+ def manifest
26
+ record do |m|
27
+
28
+ # Check for class naming collisions.
29
+ # Check for class naming collisions.
30
+ m.class_collisions controller_class_path, "#{controller_class_name}Controller", # Oauth Controller
31
+ "#{controller_class_name}Helper",
32
+ "#{controller_class_name}ClientsController",
33
+ "#{controller_class_name}ClientsHelper"
34
+ m.class_collisions class_path, "ClientApplication","OauthNonce","RequestToken","AccessToken","OauthToken"
35
+
36
+ # Controller, model, views, and test directories.
37
+ m.directory File.join('app/models', class_path)
38
+ m.directory File.join('app/controllers', controller_class_path)
39
+ m.directory File.join('app/views', controller_class_path, controller_file_name)
40
+ m.directory File.join('app/views', controller_class_path, 'oauth_clients')
41
+
42
+ m.template 'client_application.rb',File.join('app/models',"client_application.rb")
43
+ m.template 'oauth_token.rb', File.join('app/models',"oauth_token.rb")
44
+ m.template 'request_token.rb', File.join('app/models',"request_token.rb")
45
+ m.template 'access_token.rb', File.join('app/models',"access_token.rb")
46
+ m.template 'oauth_nonce.rb', File.join('app/models',"oauth_nonce.rb")
47
+
48
+ m.template 'controller.rb',File.join('app/controllers',controller_class_path,"#{controller_file_name}_controller.rb")
49
+
50
+ m.template 'clients_controller.rb',File.join('app/controllers',controller_class_path,"#{controller_file_name}_clients_controller.rb")
51
+ m.route_name 'oauth', '/oauth',:controller=>'oauth',:action=>'index'
52
+ m.route_name 'authorize', '/oauth/authorize',:controller=>'oauth',:action=>'authorize'
53
+ m.route_name 'request_token', '/oauth/request_token',:controller=>'oauth',:action=>'request_token'
54
+ m.route_name 'access_token', '/oauth/access_token',:controller=>'oauth',:action=>'access_token'
55
+ m.route_name 'test_request', '/oauth/test_request',:controller=>'oauth',:action=>'test_request'
56
+
57
+ m.route_resources "#{controller_file_name}_clients".to_sym
58
+
59
+ if !options[:test_unit]
60
+ m.directory File.join('spec')
61
+ m.directory File.join('spec/models')
62
+ m.directory File.join('spec/fixtures', class_path)
63
+ m.directory File.join('spec/controllers', controller_class_path)
64
+
65
+ m.template 'client_application_spec.rb',File.join('spec/models',"client_application_spec.rb")
66
+ m.template 'oauth_token_spec.rb', File.join('spec/models',"oauth_token_spec.rb")
67
+ m.template 'oauth_nonce_spec.rb', File.join('spec/models',"oauth_nonce_spec.rb")
68
+ m.template 'client_applications.yml',File.join('spec/fixtures',"client_applications.yml")
69
+ m.template 'oauth_tokens.yml', File.join('spec/fixtures',"oauth_tokens.yml")
70
+ m.template 'oauth_nonces.yml', File.join('spec/fixtures',"oauth_nonces.yml")
71
+ m.template 'controller_spec_helper.rb', File.join('spec/controllers', controller_class_path,"#{controller_file_name}_controller_spec_helper.rb")
72
+ m.template 'controller_spec.rb',File.join('spec/controllers',controller_class_path,"#{controller_file_name}_controller_spec.rb")
73
+ m.template 'clients_controller_spec.rb',File.join('spec/controllers',controller_class_path,"#{controller_file_name}_clients_controller_spec.rb")
74
+ else
75
+ m.directory File.join('test')
76
+ m.directory File.join('test/unit')
77
+ m.directory File.join('test/fixtures', class_path)
78
+ m.directory File.join('test/functional', controller_class_path)
79
+ m.template 'client_application_test.rb',File.join('test/unit',"client_application_test.rb")
80
+ m.template 'oauth_token_test.rb', File.join('test/unit',"oauth_token_test.rb")
81
+ m.template 'oauth_nonce_test.rb', File.join('test/unit',"oauth_nonce_test.rb")
82
+ m.template 'client_applications.yml',File.join('test/fixtures',"client_applications.yml")
83
+ m.template 'oauth_tokens.yml', File.join('test/fixtures',"oauth_tokens.yml")
84
+ m.template 'oauth_nonces.yml', File.join('test/fixtures',"oauth_nonces.yml")
85
+ m.template 'controller_test_helper.rb', File.join('test', controller_class_path,"#{controller_file_name}_controller_test_helper.rb")
86
+ m.template 'controller_test.rb',File.join('test/functional',controller_class_path,"#{controller_file_name}_controller_test.rb")
87
+ m.template 'clients_controller_test.rb',File.join('test/functional',controller_class_path,"#{controller_file_name}_clients_controller_test.rb")
88
+ end
89
+
90
+
91
+ @template_extension= options[:haml] ? "haml" : "erb"
92
+
93
+ m.template "_form.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "_form.html.#{@template_extension}")
94
+ m.template "new.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "new.html.#{@template_extension}")
95
+ m.template "index.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "index.html.#{@template_extension}")
96
+ m.template "show.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "show.html.#{@template_extension}")
97
+ m.template "edit.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "edit.html.#{@template_extension}")
98
+ m.template "authorize.html.#{@template_extension}", File.join('app/views', controller_class_path, controller_file_name, "authorize.html.#{@template_extension}")
99
+ m.template "authorize_success.html.#{@template_extension}", File.join('app/views', controller_class_path, controller_file_name, "authorize_success.html.#{@template_extension}")
100
+ m.template "authorize_failure.html.#{@template_extension}", File.join('app/views', controller_class_path, controller_file_name, "authorize_failure.html.#{@template_extension}")
101
+
102
+ unless options[:skip_migration]
103
+ m.migration_template 'migration.rb', 'db/migrate', :assigns => {
104
+ :migration_name => "CreateOauthTables"
105
+ }, :migration_file_name => "create_oauth_tables"
106
+ end
107
+ end
108
+ end
109
+
110
+ protected
111
+ def banner
112
+ "Usage: #{$0} #{spec.name}"
113
+ end
114
+
115
+ def add_options!(opt)
116
+ opt.separator ''
117
+ opt.separator 'Options:'
118
+ opt.on("--skip-migration",
119
+ "Don't generate a migration file") { |v| options[:skip_migration] = v }
120
+ opt.on("--test-unit",
121
+ "Generate the Test::Unit compatible tests instead of RSpec") { |v| options[:test_unit] = v }
122
+ opt.on("--haml",
123
+ "Templates use haml") { |v| options[:haml] = v }
124
+ end
125
+ end