dailycred 0.1.29 → 0.1.30
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +10 -2
- data/Guardfile +15 -0
- data/dailycred.gemspec +1 -1
- data/lib/generators/dailycred_generator.rb +85 -54
- data/lib/generators/templates/info.html.erb +1 -1
- data/lib/generators/templates/migration_create_user.rb +54 -14
- data/lib/generators/templates/omniauth.rb +1 -5
- data/lib/generators/templates/sessions_controller.rb +3 -3
- data/lib/generators/templates/user.rb +5 -1
- data/spec/support/dailycred_spec.rb +1 -0
- data/test/generator_test.rb +116 -0
- data/test/test_helper.rb +6 -0
- metadata +7 -59
- data/lib/generators/test.rb +0 -17
- data/localtest/.gitignore +0 -15
- data/localtest/Gemfile +0 -39
- data/localtest/README.rdoc +0 -261
- data/localtest/Rakefile +0 -7
- data/localtest/app/assets/images/rails.png +0 -0
- data/localtest/app/assets/javascripts/application.js +0 -15
- data/localtest/app/assets/stylesheets/application.css +0 -13
- data/localtest/app/controllers/application_controller.rb +0 -42
- data/localtest/app/controllers/sessions_controller.rb +0 -27
- data/localtest/app/helpers/application_helper.rb +0 -2
- data/localtest/app/mailers/.gitkeep +0 -0
- data/localtest/app/models/.gitkeep +0 -0
- data/localtest/app/models/user.rb +0 -14
- data/localtest/app/views/layouts/application.html.erb +0 -14
- data/localtest/app/views/sessions/info +0 -9
- data/localtest/config/application.rb +0 -62
- data/localtest/config/boot.rb +0 -6
- data/localtest/config/database.yml +0 -25
- data/localtest/config/environment.rb +0 -5
- data/localtest/config/environments/development.rb +0 -37
- data/localtest/config/environments/production.rb +0 -67
- data/localtest/config/environments/test.rb +0 -37
- data/localtest/config/initializers/backtrace_silencers.rb +0 -7
- data/localtest/config/initializers/inflections.rb +0 -15
- data/localtest/config/initializers/mime_types.rb +0 -5
- data/localtest/config/initializers/omniauth.rb +0 -20
- data/localtest/config/initializers/secret_token.rb +0 -7
- data/localtest/config/initializers/session_store.rb +0 -8
- data/localtest/config/initializers/wrap_parameters.rb +0 -14
- data/localtest/config/locales/en.yml +0 -5
- data/localtest/config/routes.rb +0 -61
- data/localtest/config.ru +0 -4
- data/localtest/db/migrate/20120906153457_create_users.rb +0 -21
- data/localtest/db/migrate/20120906234358_alter_column_from_users.rb +0 -6
- data/localtest/db/migrate/20120907004912_add_column_to_users.rb +0 -5
- data/localtest/db/migrate/20120907014514_add_tags_to_users.rb +0 -6
- data/localtest/db/schema.rb +0 -33
- data/localtest/db/seeds.rb +0 -7
- data/localtest/lib/assets/.gitkeep +0 -0
- data/localtest/lib/tasks/.gitkeep +0 -0
- data/localtest/log/.gitkeep +0 -0
- data/localtest/public/404.html +0 -26
- data/localtest/public/422.html +0 -26
- data/localtest/public/500.html +0 -25
- data/localtest/public/favicon.ico +0 -0
- data/localtest/public/robots.txt +0 -5
- data/localtest/script/rails +0 -6
- data/localtest/test/fixtures/.gitkeep +0 -0
- data/localtest/test/functional/.gitkeep +0 -0
- data/localtest/test/integration/.gitkeep +0 -0
- data/localtest/test/performance/browsing_test.rb +0 -12
- data/localtest/test/test_helper.rb +0 -13
- data/localtest/test/unit/.gitkeep +0 -0
- data/localtest/vendor/assets/javascripts/.gitkeep +0 -0
- data/localtest/vendor/assets/stylesheets/.gitkeep +0 -0
- data/localtest/vendor/plugins/.gitkeep +0 -0
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in omniauth-dailycred.gemspec
|
4
3
|
gemspec
|
5
4
|
|
6
|
-
gem '
|
5
|
+
gem 'rspec'
|
6
|
+
gem 'rails'
|
7
|
+
gem 'simplecov'
|
8
|
+
gem 'ruby_gntp'
|
9
|
+
gem 'growl'
|
10
|
+
gem 'spork'
|
11
|
+
gem 'guard'
|
12
|
+
gem 'guard-test'
|
13
|
+
gem 'guard-rspec'
|
14
|
+
gem 'mocha'
|
data/Guardfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :test do
|
5
|
+
watch(%r{^lib/generators/(.+)\.rb$}) { "test/generator_test.rb" }
|
6
|
+
watch(%r{^test/.+_test\.rb$}) { "test/generator_test.rb" }
|
7
|
+
watch('test/test_helper.rb') { "test/generator_test.rb" }
|
8
|
+
end
|
9
|
+
|
10
|
+
guard 'rspec', :version => 2 do
|
11
|
+
watch(%r{^spec/.+_spec\.rb$})
|
12
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/support/#{m[1]}_spec.rb" }
|
13
|
+
watch('spec/spec_helper.rb') { "spec" }
|
14
|
+
end
|
15
|
+
|
data/dailycred.gemspec
CHANGED
@@ -1,17 +1,23 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'pp'
|
3
|
+
require 'json'
|
4
|
+
require 'faraday'
|
1
5
|
class DailycredGenerator < Rails::Generators::Base
|
2
6
|
require 'faraday'
|
3
7
|
source_root File.expand_path('../templates', __FILE__)
|
4
8
|
|
5
|
-
|
6
|
-
|
9
|
+
CLIENT_ID_DEFAULT = 'YOUR_CLIENT_ID'
|
10
|
+
CLIENT_SECRET_DEFAULT = 'YOUR_SECRET_KEY'
|
7
11
|
|
8
|
-
|
12
|
+
argument :client_id, :type => :string, :default => CLIENT_ID_DEFAULT, :banner => 'dailycred_client_id'
|
13
|
+
argument :secret_key, :type => :string, :default => CLIENT_SECRET_DEFAULT, :banner => 'dailycred_secret_key'
|
14
|
+
argument :get_input, type: :string, default: 'true', enum: ['true', 'false']
|
9
15
|
|
10
16
|
APP_ROUTES_LINES =<<-EOS
|
11
|
-
match
|
17
|
+
match "/auth/:provider/callback" => "sessions#create"
|
12
18
|
match "/logout" => "sessions#destroy", :as => :logout
|
13
|
-
match "/auth" => "sessions#info", :as => :
|
14
|
-
match "/auth/dailycred", :as => :
|
19
|
+
match "/auth" => "sessions#info", :as => :auth
|
20
|
+
match "/auth/dailycred", :as => :login
|
15
21
|
match "/auth/failure" => "sessions#failure"
|
16
22
|
EOS
|
17
23
|
|
@@ -55,8 +61,8 @@ class DailycredGenerator < Rails::Generators::Base
|
|
55
61
|
|
56
62
|
APP_HELPER_LINES = <<-EOS
|
57
63
|
def connect_path(provider)
|
58
|
-
url = "/auth/dailycred?identity_provider
|
59
|
-
url += "&referrer
|
64
|
+
url = "/auth/dailycred?identity_provider=\#{provider.to_s}"
|
65
|
+
url += "&referrer=\#{request.protocol}\#{request.host_with_port}\#{request.fullpath}"
|
60
66
|
end
|
61
67
|
EOS
|
62
68
|
|
@@ -75,23 +81,27 @@ class DailycredGenerator < Rails::Generators::Base
|
|
75
81
|
*****
|
76
82
|
EOS
|
77
83
|
puts dailycred_ascii
|
78
|
-
|
84
|
+
@get_input = @get_input == "true" ? true : false
|
79
85
|
# copy initializer
|
80
86
|
template "omniauth.rb", "config/initializers/omniauth.rb"
|
87
|
+
# get client info from login if they didnt specify info
|
88
|
+
if @client_id == CLIENT_ID_DEFAULT && @get_input
|
89
|
+
get_info
|
90
|
+
end
|
81
91
|
# session_controller
|
82
92
|
copy_file "sessions_controller.rb", "app/controllers/sessions_controller.rb"
|
83
93
|
# application controller
|
84
|
-
|
94
|
+
insert_into_file "app/controllers/application_controller.rb", APP_CONTROLLER_LINES, :after => /class ApplicationController\n|class ApplicationController .*\n/
|
85
95
|
# application helper
|
86
|
-
|
96
|
+
insert_into_file "app/helpers/application_helper.rb", APP_HELPER_LINES, :after => /module ApplicationHelper\n|module ApplicationHelper .*\n/
|
87
97
|
# add user_model
|
88
98
|
copy_file "user.rb", "app/models/user.rb"
|
89
99
|
# session_controller
|
90
100
|
copy_file "migration_create_user.rb", "db/migrate/#{Time.now.strftime('%Y%m%d%H%M%S')}_create_users.rb"
|
91
101
|
# auth page
|
92
|
-
copy_file "info.html.erb", "app/views/sessions/info"
|
102
|
+
copy_file "info.html.erb", "app/views/sessions/info.html.erb"
|
93
103
|
# config/routes
|
94
|
-
inject_into_file "config/routes.rb", APP_ROUTES_LINES, :after => "
|
104
|
+
inject_into_file "config/routes.rb", APP_ROUTES_LINES, :after => ".draw do\n"
|
95
105
|
end
|
96
106
|
|
97
107
|
private
|
@@ -103,49 +113,70 @@ class DailycredGenerator < Rails::Generators::Base
|
|
103
113
|
else
|
104
114
|
puts "Invalid email and password. Try again or type 'n' to skip."
|
105
115
|
end
|
116
|
+
#ssl opts
|
117
|
+
# $stderr.puts 'getting input'
|
118
|
+
input = get_input
|
119
|
+
email, password = input[0], input[1]
|
120
|
+
# $stderr.puts 'got input'
|
121
|
+
return if email == "n"
|
122
|
+
ssl_opts = {}
|
123
|
+
if File.exists?('/etc/ssl/certs')
|
124
|
+
ssl_opts = { :ca_path => '/etc/ssl/certs'}
|
125
|
+
end
|
126
|
+
if File.exists?('/opt/local/share/curl/curl-ca-bundle.crt')
|
127
|
+
ssl_opts = { :ca_file => '/opt/local/share/curl/curl-ca-bundle.crt' }
|
128
|
+
end
|
129
|
+
# url = "https://www.dailycred.com"
|
130
|
+
# url = "http://localhost:9000"
|
131
|
+
# staging server for a very short time
|
132
|
+
url = "http://ec2-72-44-40-55.compute-1.amazonaws.com:9000"
|
133
|
+
connection = Faraday::Connection.new url, :ssl => ssl_opts
|
134
|
+
params = {
|
135
|
+
:login => email,
|
136
|
+
:pass => password,
|
137
|
+
:client_id => "dailycred"
|
138
|
+
}
|
139
|
+
response = connection.post("user/api/signin.json", params)
|
140
|
+
json = JSON.parse(response.body)
|
141
|
+
if !json["worked"]
|
142
|
+
# wrong password
|
143
|
+
p ''
|
144
|
+
get_info false
|
145
|
+
end
|
146
|
+
access_token = json["access_token"]
|
147
|
+
response = connection.post("graph/clientinfo.json", :access_token => access_token)
|
148
|
+
json = JSON.parse(response.body)
|
149
|
+
if !json["worked"]
|
150
|
+
p "There was an error retrieving your account information. Please manually configure your API keys in config/initializers/omniauth.rb"
|
151
|
+
return
|
152
|
+
end
|
153
|
+
@client_id = json["clientId"]
|
154
|
+
@secret_key = json["clientSecret"]
|
155
|
+
gsub_file("config/initializers/omniauth.rb", /YOUR_CLIENT_ID/, @client_id) if @client_id
|
156
|
+
gsub_file("config/initializers/omniauth.rb", /YOUR_SECRET_KEY/, @secret_key) if @secret_key
|
157
|
+
end
|
158
|
+
|
159
|
+
def get_input
|
106
160
|
puts ''
|
107
|
-
print "
|
161
|
+
print "Email:"
|
108
162
|
email = gets.chomp
|
109
|
-
if email
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
118
|
-
ssl_opts = {}
|
119
|
-
if File.exists?('/etc/ssl/certs')
|
120
|
-
ssl_opts = { :ca_path => '/etc/ssl/certs'}
|
121
|
-
end
|
122
|
-
if File.exists?('/opt/local/share/curl/curl-ca-bundle.crt')
|
123
|
-
ssl_opts = { :ca_file => '/opt/local/share/curl/curl-ca-bundle.crt' }
|
124
|
-
end
|
125
|
-
connection = Faraday::Connection.new "http://localhost:9000/", :ssl => ssl_opts
|
126
|
-
params = {
|
127
|
-
:login => email
|
128
|
-
:pass => password
|
129
|
-
:client_id => "dailycred"
|
130
|
-
}
|
131
|
-
response = connection.post("/user/api/signin.json", params)
|
132
|
-
p response_body
|
133
|
-
json = JSON.parse(response.body)
|
134
|
-
if !json["worked"]
|
135
|
-
# wrong password
|
136
|
-
get_info false
|
137
|
-
end
|
138
|
-
access_token = json["access_token"]
|
139
|
-
p access_token
|
140
|
-
response = connection.post("graph/clientinfo.json", :access_token => access_token)
|
141
|
-
json = JSON.parse(response.body)
|
142
|
-
if !json["worked"]
|
143
|
-
# weird error
|
144
|
-
end
|
145
|
-
client_id = json["clientId"]
|
146
|
-
client_secret = json["clientSecret"]
|
147
|
-
file_gsub "config/initializers/omniauth.rb", "YOUR_CLIENT_ID", client_id
|
148
|
-
file_gsub "config/initializers/omniauth.rb", "YOUR_SECRET_KEY", client_secret
|
163
|
+
return email, nil if email == "n"
|
164
|
+
stty_settings = %x[stty -g]
|
165
|
+
print 'Password: '
|
166
|
+
begin
|
167
|
+
%x[stty -echo]
|
168
|
+
password = gets.chomp
|
169
|
+
ensure
|
170
|
+
%x[stty #{stty_settings}]
|
149
171
|
end
|
172
|
+
return email, password
|
173
|
+
end
|
174
|
+
|
175
|
+
private
|
176
|
+
|
177
|
+
def show obj
|
178
|
+
$stderr.puts obj
|
179
|
+
end
|
180
|
+
|
150
181
|
|
151
182
|
end
|
@@ -3,5 +3,5 @@
|
|
3
3
|
<%= link_to 'Logout', logout_path %>
|
4
4
|
</p>
|
5
5
|
<% else %>
|
6
|
-
<%= link_to 'Login In', login_path %> or <%= link_to 'Sign Up',
|
6
|
+
<%= link_to 'Login In', login_path(:action => 'signin') %> or <%= link_to 'Sign Up', login_path(:identity_provider => :facebook) %>
|
7
7
|
<% end %>
|
@@ -1,24 +1,64 @@
|
|
1
1
|
class CreateUsers < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
3
|
+
if !table_exists? :users
|
4
|
+
create_table :users do |t|
|
5
|
+
t.string :provider
|
6
|
+
t.string :uid
|
7
|
+
t.string :email
|
8
|
+
t.integer :created, :limit => 8
|
9
|
+
t.string :username
|
10
|
+
t.boolean :verified
|
11
|
+
t.boolean :admin
|
12
|
+
t.string :referred_by
|
13
|
+
t.string :token
|
14
|
+
t.text :facebook
|
15
|
+
t.text :tags
|
16
|
+
t.text :referred
|
17
|
+
t.text :google
|
18
|
+
t.text :twitter
|
19
|
+
t.text :github
|
16
20
|
|
17
|
-
|
21
|
+
t.timestamps
|
22
|
+
end
|
23
|
+
else
|
24
|
+
safe_column :users, :provider, :string
|
25
|
+
safe_column :users, :uid, :string
|
26
|
+
safe_column :users, :email, :string
|
27
|
+
safe_column :users, :created, :integer
|
28
|
+
safe_column :users, :username, :string
|
29
|
+
safe_column :users, :verified, :booleanied
|
30
|
+
safe_column :users, :admin, :boolean
|
31
|
+
safe_column :users, :referred, :string
|
32
|
+
safe_column :users, :token, :string
|
33
|
+
safe_column :users, :facebook, :text
|
34
|
+
safe_column :users, :tags, :text
|
35
|
+
safe_column :users, :referred, :text
|
36
|
+
safe_column :users, :google, :text
|
37
|
+
safe_column :users, :twitter, :text
|
38
|
+
safe_column :users, :github, :text
|
18
39
|
end
|
19
40
|
end
|
20
41
|
|
21
42
|
def self.down
|
22
43
|
drop_table :users
|
23
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def table_exists? table
|
49
|
+
ActiveRecord::Base.connection.table_exists?(table.to_s)
|
50
|
+
end
|
51
|
+
|
52
|
+
def column_exists?(table, column)
|
53
|
+
begin
|
54
|
+
ActiveRecord::Base.connection.columns(table.to_s).map(&:name).include?(column.to_s)
|
55
|
+
rescue NoMethodError #actual_columns is empty and it doesn't respond to the map method
|
56
|
+
false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def safe_column table, name, type
|
61
|
+
add_column table.to_sym, name.to_sym, type.to_sym unless table_exists? table
|
62
|
+
end
|
63
|
+
|
24
64
|
end
|
@@ -4,11 +4,7 @@ Rails.configuration.DAILYCRED_SECRET_KEY = "<%= secret_key %>"
|
|
4
4
|
dc_id = Rails.configuration.DAILYCRED_CLIENT_ID
|
5
5
|
dc_secret = Rails.configuration.DAILYCRED_SECRET_KEY
|
6
6
|
|
7
|
-
dc_options = { :client_options => {
|
8
|
-
:site => "https://www.dailycred.com",
|
9
|
-
:authorize_url => '/oauth/authorize',
|
10
|
-
:token_url => '/oauth/access_token'
|
11
|
-
} }
|
7
|
+
dc_options = { :client_options => {} }
|
12
8
|
|
13
9
|
if File.exists?('/etc/ssl/certs')
|
14
10
|
dc_options[:client_options][:ssl] = { :ca_path => '/etc/ssl/certs'}
|
@@ -6,17 +6,17 @@ class SessionsController < ApplicationController
|
|
6
6
|
def create
|
7
7
|
@user = User.find_or_create_with_omniauth auth_hash
|
8
8
|
session[:user_id] = @user.id
|
9
|
-
redirect_to
|
9
|
+
redirect_to auth_path
|
10
10
|
end
|
11
11
|
|
12
12
|
#GET /logout
|
13
13
|
def destroy
|
14
14
|
session[:user_id] = nil
|
15
|
-
redirect_to
|
15
|
+
redirect_to auth_path
|
16
16
|
end
|
17
17
|
|
18
18
|
def failure
|
19
|
-
redirect_to
|
19
|
+
redirect_to auth_path, notice: params[:message]
|
20
20
|
end
|
21
21
|
|
22
22
|
def info
|
@@ -1,9 +1,13 @@
|
|
1
1
|
class User < ActiveRecord::Base
|
2
2
|
serialize :facebook, Hash
|
3
|
+
serialize :twitter, Hash
|
4
|
+
serialize :google, Hash
|
5
|
+
serialize :github, Hash
|
3
6
|
serialize :tags, Array
|
4
7
|
serialize :referred, Array
|
5
8
|
|
6
|
-
attr_accessible :email, :
|
9
|
+
attr_accessible :email, :username, :created, :verified, :admin, :referred_by, :referred,
|
10
|
+
:facebook, :tags, :provider, :uid, :token, :twitter, :google, :github
|
7
11
|
|
8
12
|
def self.find_or_create_with_omniauth(model)
|
9
13
|
@user = User.find_by_provider_and_uid(model[:provider], model[:uid]) || User.new
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
# require 'mocha'
|
3
|
+
require_relative "../lib/generators/dailycred_generator.rb"
|
4
|
+
class GeneratorTest < Rails::Generators::TestCase
|
5
|
+
tests DailycredGenerator
|
6
|
+
destination File.expand_path("./tmp/myproject", File.dirname(__FILE__))
|
7
|
+
|
8
|
+
setup :prepare_destination
|
9
|
+
|
10
|
+
setup do
|
11
|
+
# Must set before requiring generator libs.
|
12
|
+
TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
|
13
|
+
PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
|
14
|
+
app_root = File.join(TMP_ROOT, PROJECT_NAME)
|
15
|
+
if defined?(APP_ROOT)
|
16
|
+
APP_ROOT.replace(app_root)
|
17
|
+
else
|
18
|
+
APP_ROOT = app_root
|
19
|
+
end
|
20
|
+
if defined?(RAILS_ROOT)
|
21
|
+
RAILS_ROOT.replace(app_root)
|
22
|
+
else
|
23
|
+
RAILS_ROOT = app_root
|
24
|
+
end
|
25
|
+
Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config")
|
26
|
+
File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
|
27
|
+
f.puts "ActionController::Routing::Routes.draw do\n\nend"
|
28
|
+
end
|
29
|
+
Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app")
|
30
|
+
Dir.mkdir("#{RAILS_ROOT}/app/controllers") unless File.exists?("#{RAILS_ROOT}/app/controllers")
|
31
|
+
File.open("#{RAILS_ROOT}/app/controllers/application_controller.rb", 'w') do |f|
|
32
|
+
f.puts "class ApplicationController < ActionController::Base\n\nend"
|
33
|
+
end
|
34
|
+
Dir.mkdir("#{RAILS_ROOT}/app/helpers")
|
35
|
+
File.open("#{RAILS_ROOT}/app/helpers/application_helper.rb", 'w') do |f|
|
36
|
+
f.puts "module ApplicationHelper\n\nend"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
teardown do
|
41
|
+
FileUtils.rm_rf "#{RAILS_ROOT}/app"
|
42
|
+
FileUtils.rm_rf "#{RAILS_ROOT}/config"
|
43
|
+
FileUtils.rm_rf "#{RAILS_ROOT}/db"
|
44
|
+
end
|
45
|
+
|
46
|
+
test "generator works with input" do
|
47
|
+
test_generator ["aaa","bbb"]
|
48
|
+
assert_credentials "aaa", "bbb"
|
49
|
+
end
|
50
|
+
|
51
|
+
test "generator works with login" do
|
52
|
+
generator_class.any_instance.stubs(:get_input).returns(["localtest@dailycred.com","password"])
|
53
|
+
test_generator
|
54
|
+
assert_credentials "e92e20bf-e0a4-49b4-8a82-ff1b65d80017", "9adf81a8-ce97-4bcb-9c1f-c09f5fc7b6b8-0d1a4553-496d-450e-80fd-9e8d0552a920"
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def test_generator args=[]
|
60
|
+
run_generator args
|
61
|
+
assert_file "config/initializers/omniauth.rb" do |config|
|
62
|
+
assert_true config.include? "Rails.application.config.middleware.use"
|
63
|
+
# assert_true config.include? 'Rails.configuration.DAILYCRED_CLIENT_ID = "YOUR_CLIENT_ID"'
|
64
|
+
# assert_true config.include? 'Rails.configuration.DAILYCRED_SECRET_KEY = "YOUR_SECRET_KEY"'
|
65
|
+
end
|
66
|
+
|
67
|
+
assert_file "config/routes.rb", /(#{Regexp.escape('match "/auth/:provider/callback" => "sessions#create"')})/
|
68
|
+
assert_file "config/routes.rb", /(#{Regexp.escape('match "/logout" => "sessions#destroy", :as => :logout')})/
|
69
|
+
assert_file "config/routes.rb", /(#{Regexp.escape('match "/auth" => "sessions#info", :as => :auth')})/
|
70
|
+
assert_file "config/routes.rb", /(#{Regexp.escape('match "/auth/dailycred", :as => :login')})/
|
71
|
+
assert_file "config/routes.rb", /(#{Regexp.escape('match "/auth/failure" => "sessions#failure"')})/
|
72
|
+
|
73
|
+
assert_file "app/controllers/sessions_controller.rb" do |controller|
|
74
|
+
assert_instance_method :create, controller
|
75
|
+
assert_instance_method :destroy, controller
|
76
|
+
assert_instance_method :failure, controller
|
77
|
+
assert_instance_method :info, controller
|
78
|
+
end
|
79
|
+
|
80
|
+
assert_file "app/controllers/application_controller.rb" do |controller|
|
81
|
+
assert_instance_method :current_user, controller
|
82
|
+
assert_instance_method :set_state, controller
|
83
|
+
assert_instance_method :authenticate, controller
|
84
|
+
assert_instance_method :dailycred, controller
|
85
|
+
end
|
86
|
+
|
87
|
+
assert_file "app/helpers/application_helper.rb" do |helper|
|
88
|
+
assert_instance_method :connect_path, helper
|
89
|
+
end
|
90
|
+
|
91
|
+
assert_file "app/models/user.rb" do |model|
|
92
|
+
# assert_true model.include? "attr_accessible :email, :username, :created, :verified, :admin, :referred_by, :referred, :facebook, :tags, :provider, :uid, :token"
|
93
|
+
assert_class_method :find_or_create_with_omniauth, model
|
94
|
+
assert_true model.include? "serialize :facebook, Hash"
|
95
|
+
assert_true model.include? "serialize :tags, Array"
|
96
|
+
assert_true model.include? "serialize :referred, Array"
|
97
|
+
assert_true model.include? "serialize :twitter, Hash"
|
98
|
+
assert_true model.include? "serialize :google, Hash"
|
99
|
+
assert_true model.include? "serialize :github, Hash"
|
100
|
+
end
|
101
|
+
|
102
|
+
assert_migration "db/migrate/create_users.rb" do |migration|
|
103
|
+
assert_true migration.include? ":twitter"
|
104
|
+
assert_true migration.include? ":github"
|
105
|
+
assert_true migration.include? ":google"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def assert_credentials client_id, client_secret
|
110
|
+
assert_file "config/initializers/omniauth.rb" do |config|
|
111
|
+
assert_true config.include? "Rails.configuration.DAILYCRED_CLIENT_ID = \"#{client_id}\""
|
112
|
+
assert_true config.include? "Rails.configuration.DAILYCRED_SECRET_KEY = \"#{client_secret}\""
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dailycred
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.30
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
@@ -52,6 +52,7 @@ extra_rdoc_files: []
|
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
54
|
- Gemfile
|
55
|
+
- Guardfile
|
55
56
|
- LICENSE
|
56
57
|
- README.md
|
57
58
|
- Rakefile
|
@@ -77,70 +78,15 @@ files:
|
|
77
78
|
- lib/generators/templates/omniauth.rb
|
78
79
|
- lib/generators/templates/sessions_controller.rb
|
79
80
|
- lib/generators/templates/user.rb
|
80
|
-
- lib/generators/test.rb
|
81
81
|
- lib/middleware/middleware.rb
|
82
82
|
- lib/omniauth-dailycred/version.rb
|
83
83
|
- lib/omniauth/strategies/dailycred.rb
|
84
|
-
- localtest/.gitignore
|
85
|
-
- localtest/Gemfile
|
86
|
-
- localtest/README.rdoc
|
87
|
-
- localtest/Rakefile
|
88
|
-
- localtest/app/assets/images/rails.png
|
89
|
-
- localtest/app/assets/javascripts/application.js
|
90
|
-
- localtest/app/assets/stylesheets/application.css
|
91
|
-
- localtest/app/controllers/application_controller.rb
|
92
|
-
- localtest/app/controllers/sessions_controller.rb
|
93
|
-
- localtest/app/helpers/application_helper.rb
|
94
|
-
- localtest/app/mailers/.gitkeep
|
95
|
-
- localtest/app/models/.gitkeep
|
96
|
-
- localtest/app/models/user.rb
|
97
|
-
- localtest/app/views/layouts/application.html.erb
|
98
|
-
- localtest/app/views/sessions/info
|
99
|
-
- localtest/config.ru
|
100
|
-
- localtest/config/application.rb
|
101
|
-
- localtest/config/boot.rb
|
102
|
-
- localtest/config/database.yml
|
103
|
-
- localtest/config/environment.rb
|
104
|
-
- localtest/config/environments/development.rb
|
105
|
-
- localtest/config/environments/production.rb
|
106
|
-
- localtest/config/environments/test.rb
|
107
|
-
- localtest/config/initializers/backtrace_silencers.rb
|
108
|
-
- localtest/config/initializers/inflections.rb
|
109
|
-
- localtest/config/initializers/mime_types.rb
|
110
|
-
- localtest/config/initializers/omniauth.rb
|
111
|
-
- localtest/config/initializers/secret_token.rb
|
112
|
-
- localtest/config/initializers/session_store.rb
|
113
|
-
- localtest/config/initializers/wrap_parameters.rb
|
114
|
-
- localtest/config/locales/en.yml
|
115
|
-
- localtest/config/routes.rb
|
116
|
-
- localtest/db/migrate/20120906153457_create_users.rb
|
117
|
-
- localtest/db/migrate/20120906234358_alter_column_from_users.rb
|
118
|
-
- localtest/db/migrate/20120907004912_add_column_to_users.rb
|
119
|
-
- localtest/db/migrate/20120907014514_add_tags_to_users.rb
|
120
|
-
- localtest/db/schema.rb
|
121
|
-
- localtest/db/seeds.rb
|
122
|
-
- localtest/lib/assets/.gitkeep
|
123
|
-
- localtest/lib/tasks/.gitkeep
|
124
|
-
- localtest/log/.gitkeep
|
125
|
-
- localtest/public/404.html
|
126
|
-
- localtest/public/422.html
|
127
|
-
- localtest/public/500.html
|
128
|
-
- localtest/public/favicon.ico
|
129
|
-
- localtest/public/robots.txt
|
130
|
-
- localtest/script/rails
|
131
|
-
- localtest/test/fixtures/.gitkeep
|
132
|
-
- localtest/test/functional/.gitkeep
|
133
|
-
- localtest/test/integration/.gitkeep
|
134
|
-
- localtest/test/performance/browsing_test.rb
|
135
|
-
- localtest/test/test_helper.rb
|
136
|
-
- localtest/test/unit/.gitkeep
|
137
|
-
- localtest/vendor/assets/javascripts/.gitkeep
|
138
|
-
- localtest/vendor/assets/stylesheets/.gitkeep
|
139
|
-
- localtest/vendor/plugins/.gitkeep
|
140
84
|
- spec/helper_spec.rb
|
141
85
|
- spec/omniauth/strategies/dailycred_spec.rb
|
142
86
|
- spec/support/dailycred_spec.rb
|
143
87
|
- spec/support/shared_examples.rb
|
88
|
+
- test/generator_test.rb
|
89
|
+
- test/test_helper.rb
|
144
90
|
homepage: https://www.dailycred.com
|
145
91
|
licenses: []
|
146
92
|
post_install_message:
|
@@ -170,4 +116,6 @@ test_files:
|
|
170
116
|
- spec/omniauth/strategies/dailycred_spec.rb
|
171
117
|
- spec/support/dailycred_spec.rb
|
172
118
|
- spec/support/shared_examples.rb
|
119
|
+
- test/generator_test.rb
|
120
|
+
- test/test_helper.rb
|
173
121
|
has_rdoc:
|
data/lib/generators/test.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
stty_settings = %x[stty -g]
|
2
|
-
print 'Password: '
|
3
|
-
|
4
|
-
begin
|
5
|
-
%x[stty -echo]
|
6
|
-
password = gets
|
7
|
-
ensure
|
8
|
-
%x[stty #{stty_settings}]
|
9
|
-
end
|
10
|
-
|
11
|
-
puts
|
12
|
-
|
13
|
-
print 'regular info: '
|
14
|
-
regular_info = gets
|
15
|
-
|
16
|
-
puts "password: #{password}"
|
17
|
-
puts "regular: #{regular_info}"
|
data/localtest/.gitignore
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
-
#
|
3
|
-
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
-
# or operating system, you probably want to add a global ignore instead:
|
5
|
-
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
-
|
7
|
-
# Ignore bundler config
|
8
|
-
/.bundle
|
9
|
-
|
10
|
-
# Ignore the default SQLite database.
|
11
|
-
/db/*.sqlite3
|
12
|
-
|
13
|
-
# Ignore all logfiles and tempfiles.
|
14
|
-
/log/*.log
|
15
|
-
/tmp
|