dailycred 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +7 -1
- data/dailycred.gemspec +2 -2
- data/dummy/.gitignore +3 -2
- data/dummy/Gemfile +14 -29
- data/dummy/README.rdoc +15 -248
- data/dummy/Rakefile +0 -1
- data/dummy/app/assets/javascripts/application.js +2 -1
- data/dummy/app/controllers/application_controller.rb +3 -14
- data/dummy/app/views/layouts/application.html.erb +2 -6
- data/dummy/bin/bundle +3 -0
- data/dummy/bin/rails +4 -0
- data/dummy/bin/rake +4 -0
- data/dummy/config/application.rb +2 -42
- data/dummy/config/boot.rb +0 -2
- data/dummy/config/environment.rb +2 -2
- data/dummy/config/environments/development.rb +9 -19
- data/dummy/config/environments/production.rb +40 -27
- data/dummy/config/environments/test.rb +12 -13
- data/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/dummy/config/initializers/inflections.rb +6 -5
- data/dummy/config/initializers/omniauth.rb +8 -4
- data/dummy/config/initializers/secret_token.rb +6 -1
- data/dummy/config/initializers/session_store.rb +1 -6
- data/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/dummy/config/locales/en.yml +20 -2
- data/dummy/config/routes.rb +15 -26
- data/dummy/db/migrate/{20121218124721_create_users.rb → 20130417131939_create_users.rb} +2 -2
- data/dummy/db/schema.rb +8 -20
- data/dummy/public/404.html +2 -1
- data/dummy/public/422.html +1 -1
- data/dummy/public/500.html +2 -1
- data/dummy/public/robots.txt +1 -1
- data/dummy/test/models/.keep +0 -0
- data/dummy/test/test_helper.rb +11 -58
- data/dummy/vendor/assets/javascripts/.keep +0 -0
- data/dummy/vendor/assets/stylesheets/.keep +0 -0
- data/lib/dailycred/client.rb +1 -0
- data/lib/dailycred/version.rb +1 -1
- data/lib/dailycred.rb +0 -1
- data/spec/helper_spec.rb +0 -2
- metadata +24 -44
- data/dummy/Guardfile +0 -31
- data/dummy/app/assets/javascripts/posts.js.coffee +0 -3
- data/dummy/app/assets/stylesheets/posts.css.scss +0 -3
- data/dummy/app/assets/stylesheets/scaffolds.css.scss +0 -69
- data/dummy/app/controllers/posts_controller.rb +0 -86
- data/dummy/app/helpers/posts_helper.rb +0 -2
- data/dummy/app/models/post.rb +0 -3
- data/dummy/app/views/posts/_form.html.erb +0 -21
- data/dummy/app/views/posts/edit.html.erb +0 -6
- data/dummy/app/views/posts/index.html.erb +0 -23
- data/dummy/app/views/posts/new.html.erb +0 -5
- data/dummy/app/views/posts/show.html.erb +0 -10
- data/dummy/db/migrate/20120926012555_create_posts.rb +0 -9
- data/dummy/db/migrate/20121002192037_update_users_2.rb +0 -70
- data/dummy/db/migrate/20121108192739_add_column_to_posts.rb +0 -5
- data/dummy/db/migrate/20121218205329_change_created_column.rb +0 -5
- data/dummy/script/rails +0 -6
- data/dummy/test/fixtures/posts.yml +0 -7
- data/dummy/test/fixtures/users.yml +0 -3
- data/dummy/test/functional/posts_controller_test.rb +0 -51
- data/dummy/test/performance/browsing_test.rb +0 -12
- data/dummy/test/unit/helpers/posts_helper_test.rb +0 -4
- data/dummy/test/unit/post_test.rb +0 -7
- data/dummy/test/unit/user_test.rb +0 -77
- data/lib/omniauth/strategies/dailycred.rb +0 -81
- data/spec/omniauth/strategies/dailycred_spec.rb +0 -70
- /data/dummy/app/{mailers/.gitkeep → controllers/concerns/.keep} +0 -0
- /data/dummy/app/{models/.gitkeep → mailers/.keep} +0 -0
- /data/dummy/{lib/assets/.gitkeep → app/models/.keep} +0 -0
- /data/dummy/{lib/tasks/.gitkeep → app/models/concerns/.keep} +0 -0
- /data/dummy/{log/.gitkeep → lib/assets/.keep} +0 -0
- /data/dummy/{test/fixtures/.gitkeep → lib/tasks/.keep} +0 -0
- /data/dummy/{test/functional/.gitkeep → log/.keep} +0 -0
- /data/dummy/test/{integration/.gitkeep → controllers/.keep} +0 -0
- /data/dummy/test/{unit/.gitkeep → fixtures/.keep} +0 -0
- /data/dummy/{vendor/assets/javascripts/.gitkeep → test/helpers/.keep} +0 -0
- /data/dummy/{vendor/assets/stylesheets/.gitkeep → test/integration/.keep} +0 -0
- /data/dummy/{vendor/plugins/.gitkeep → test/mailers/.keep} +0 -0
@@ -1,77 +0,0 @@
|
|
1
|
-
require_relative '../test_helper.rb'
|
2
|
-
class UserTest < ActiveSupport::TestCase
|
3
|
-
setup do
|
4
|
-
@user = users(:basic)
|
5
|
-
end
|
6
|
-
test 'tagging a user' do
|
7
|
-
@user.tag 'awesome'
|
8
|
-
assert_tag 'awesome'
|
9
|
-
end
|
10
|
-
test 'untagging a user' do
|
11
|
-
t = 'bad'
|
12
|
-
@user.tag t
|
13
|
-
assert_tag t
|
14
|
-
@user.untag t
|
15
|
-
assert_not_tag t
|
16
|
-
end
|
17
|
-
|
18
|
-
test 'resetting a password' do
|
19
|
-
assert_true json_response(@user.reset_password)['worked']
|
20
|
-
end
|
21
|
-
|
22
|
-
test 'updating from dailycred' do
|
23
|
-
dc = {
|
24
|
-
email: 'hank@2.com',
|
25
|
-
tags: ['hello','awesome'],
|
26
|
-
referred: ['danny', 'betty'],
|
27
|
-
username: 'hstove',
|
28
|
-
created: 111222333,
|
29
|
-
verified: false,
|
30
|
-
admin: false,
|
31
|
-
referred_by: 'marky',
|
32
|
-
referred: ['chris', 'mike'],
|
33
|
-
facebook: {
|
34
|
-
id: 100203,
|
35
|
-
email: 'hank@facebook.com'
|
36
|
-
},
|
37
|
-
provider: 'dailycred',
|
38
|
-
token: 'ha243k',
|
39
|
-
twitter: {
|
40
|
-
screen_name: 'heynky'
|
41
|
-
},
|
42
|
-
google: {
|
43
|
-
email: 'hstove@gg.com'
|
44
|
-
},
|
45
|
-
github: {
|
46
|
-
repos: ['123','ruby on rails']
|
47
|
-
},
|
48
|
-
subscribed: false,
|
49
|
-
display: 'hanky'
|
50
|
-
}
|
51
|
-
@user.update_from_dailycred dc
|
52
|
-
dc.each do |k,v|
|
53
|
-
assert_equal v, @user[k], "user should have value of |#{v}| for |#{k}| but was |#{@user[k].to_s}|"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
test 'firing an event' do
|
58
|
-
assert_true json_response(@user.fire_event 'got tested')['worked']
|
59
|
-
end
|
60
|
-
|
61
|
-
test 'making a referral link' do
|
62
|
-
id = @user.uid
|
63
|
-
assert_equal @user.referral_link('http://me.com'), "https://www.dailycred.com/r/#{id}?redirect_uri=http://me.com"
|
64
|
-
end
|
65
|
-
|
66
|
-
def json_response response
|
67
|
-
JSON.parse response.body
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def assert_tag tag
|
72
|
-
assert_true @user.tags.include?(tag), "user should have tag: #{tag} but has tags: #{@user.tags}"
|
73
|
-
end
|
74
|
-
def assert_not_tag tag
|
75
|
-
assert_false @user.tags.include?(tag), "user should not have tag: #{tag} but has tags: #{@user.tags}"
|
76
|
-
end
|
77
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'omniauth-oauth2'
|
2
|
-
require 'faraday'
|
3
|
-
require 'net/https'
|
4
|
-
require 'json'
|
5
|
-
require 'pp'
|
6
|
-
|
7
|
-
# #The Dailycred Omniauth Strategy
|
8
|
-
module OmniAuth
|
9
|
-
module Strategies
|
10
|
-
class Dailycred < OmniAuth::Strategies::OAuth2
|
11
|
-
|
12
|
-
# default options
|
13
|
-
option :client_options, {
|
14
|
-
:site => "https://www.dailycred.com",
|
15
|
-
:authorize_url => '/connect',
|
16
|
-
:token_url => '/oauth/access_token'
|
17
|
-
}
|
18
|
-
|
19
|
-
# allows parameters to be passed through
|
20
|
-
AUTH_PARAMS = ["action","identity_provider","referrer", "access_token"]
|
21
|
-
|
22
|
-
option :authorize_options, OmniAuth::Strategies::Dailycred::AUTH_PARAMS
|
23
|
-
|
24
|
-
uid { user['uid'] }
|
25
|
-
|
26
|
-
info do
|
27
|
-
user
|
28
|
-
end
|
29
|
-
|
30
|
-
alias :old_request_phase :request_phase
|
31
|
-
|
32
|
-
|
33
|
-
def authorize_params
|
34
|
-
super.tap do |params|
|
35
|
-
params[:state] ||= {}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# this step allows auth_params to be added to the url
|
40
|
-
def request_phase
|
41
|
-
p session['omniauth.state']
|
42
|
-
OmniAuth::Strategies::Dailycred::AUTH_PARAMS.each do |param|
|
43
|
-
val = session['omniauth.params'][param]
|
44
|
-
if val && !val.empty?
|
45
|
-
options[:authorize_params] ||= {}
|
46
|
-
options[:authorize_params].merge!(param => val)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
old_request_phase
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
# This is the phase where the gem calls me.json, which returns information about the user
|
55
|
-
def user
|
56
|
-
return @duser if !@duser.nil?
|
57
|
-
connection = Faraday::Connection.new options.client_options[:site], :ssl => options.client_options[:ssl]
|
58
|
-
response = connection.get("/graph/me.json?access_token=#{access_token.token}")
|
59
|
-
json = JSON.parse(response.body)
|
60
|
-
pp json if options[:verbose]
|
61
|
-
@duser = {'token' => access_token.token}
|
62
|
-
@duser['provider'] = 'dailycred'
|
63
|
-
@duser['uid'] = json['id'] || json['user_id']
|
64
|
-
json.each do |k,v|
|
65
|
-
@duser[k] = v
|
66
|
-
end
|
67
|
-
json["identities"].each do |k, v|
|
68
|
-
@duser[k] = v
|
69
|
-
@duser[k][:access_token] = json["access_tokens"][k]
|
70
|
-
end if !json["identities"].nil?
|
71
|
-
pp @duser if options[:verbose]
|
72
|
-
created = json['created'] / 1000
|
73
|
-
@duser['created'] = DateTime.strptime(created.to_s, '%s')
|
74
|
-
@duser.delete("id")
|
75
|
-
|
76
|
-
@duser
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require_relative '../../helper_spec.rb'
|
2
|
-
require 'omniauth'
|
3
|
-
require 'dailycred'
|
4
|
-
describe OmniAuth::Strategies::Dailycred do
|
5
|
-
subject do
|
6
|
-
OmniAuth::Strategies::Dailycred.new(nil, @options || {})
|
7
|
-
end
|
8
|
-
|
9
|
-
OmniAuth.config.test_mode = true
|
10
|
-
OmniAuth.config.add_mock(:dailycred, {:id => '12345',
|
11
|
-
:email => 'Test@test.com',
|
12
|
-
:username => 'test',
|
13
|
-
:created => 45678,
|
14
|
-
:verified => false,
|
15
|
-
:admin => true,
|
16
|
-
:referred_by => 'dave' })
|
17
|
-
|
18
|
-
it_should_behave_like 'an oauth2 strategy'
|
19
|
-
|
20
|
-
context "general" do
|
21
|
-
it "should be called dailycred" do
|
22
|
-
subject.options.name.should eq('dailycred')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
describe '#client' do
|
28
|
-
it 'should have the correct dailycred site' do
|
29
|
-
subject.client.site.should eq("https://www.dailycred.com")
|
30
|
-
end
|
31
|
-
it 'should have the correct authorization url' do
|
32
|
-
subject.client.options[:authorize_url].should eq("/connect")
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should have the correct token url' do
|
36
|
-
subject.client.options[:token_url].should eq('/oauth/access_token')
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# describe 'getting info' do
|
41
|
-
# before do
|
42
|
-
# @access_token = double("token" => 'test_token')
|
43
|
-
# @dailycred_user = double( :id => '12345',
|
44
|
-
# :email => 'test@test.com',
|
45
|
-
# :username => 'test',
|
46
|
-
# :id => 45678,
|
47
|
-
# :verified => false,
|
48
|
-
# :admin => true,
|
49
|
-
# :referred_by => 'dave' )
|
50
|
-
|
51
|
-
# subject.stub(:access_token) { @access_token }
|
52
|
-
|
53
|
-
# @dailycred_user.should_receive(:fetch).and_return(@dailycred_user)
|
54
|
-
# end
|
55
|
-
|
56
|
-
# it 'should set the correct info based on user' do
|
57
|
-
# subject.info.should == {:id => '12345',
|
58
|
-
# :email => 'test@test.com',
|
59
|
-
# :username => 'test',
|
60
|
-
# :created => 45678,
|
61
|
-
# :verified => false,
|
62
|
-
# :admin => true,
|
63
|
-
# :referred_by => 'dave' }
|
64
|
-
# end
|
65
|
-
|
66
|
-
# it 'set the correct uid based on user' do
|
67
|
-
# subject.id.should == '12345'
|
68
|
-
# end
|
69
|
-
# end
|
70
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|