dailycred 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ gem 'spork'
11
11
  gem 'guard'
12
12
  gem 'guard-test'
13
13
  gem 'guard-rspec'
14
- gem 'mocha'
14
+ gem "mocha", '0.12.1', :require => false
15
15
  gem 'fl-rocco'
16
16
  gem 'redcarpet', '~> 1.17'
17
17
  gem 'markdown'
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Dailycred
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/dailycred/dailycred.png?branch=master)](https://travis-ci.org/dailycred/dailycred)
4
+
3
5
  ## Introduction
4
6
 
5
7
  The Dailycred ruby gem is everything you need to get off the ground running with robust authentication. It includes an [omniauth](https://github.com/intridea/omniauth) provider and a generator to create necessary models and controllers. The generated authentication structure is inspired by [nifty-generators](https://github.com/ryanb/nifty-generators). To get started using Dailycred with Ruby on Rails, the first thing you need to do is add the dailycred gem to your gemfile:
@@ -56,7 +58,7 @@ To use a social sign-in service instead of email, and password, use `connect_pat
56
58
 
57
59
  <%= link_to 'sign in with facebook', connect_path(:identity_provider => :facebook) %>
58
60
 
59
- The `identity_provider` can be one of `facebook`, `google`, or `twitter.`
61
+ The `identity_provider` can be one of `facebook`, `google`, `twitter`, `disqus`, or `instagram`.
60
62
 
61
63
  After a user has social connected, their social data is serialized into individual fields in the user model. The serialized object is the exact same as what the social provider's graph response returns. For example:
62
64
 
@@ -160,7 +162,7 @@ To easily build referral URLs to track sharing amongst your users, use `referral
160
162
  Testing controllers that have the `authenticate` before filter is easy:
161
163
 
162
164
  # with mocha
163
- @controller.expects(:current_user).returns(@user)
165
+ @controller.stubs(:current_user).returns(@user)
164
166
 
165
167
  See `dummy/test/functional/post_controller_test.rb` for an example.
166
168
 
data/Rakefile CHANGED
@@ -2,31 +2,42 @@
2
2
  require "bundler/gem_tasks"
3
3
  require 'rspec/core/rake_task'
4
4
 
5
- desc 'Default: run specs.'
6
- task :default => :spec
7
-
8
5
  desc "Run specs"
9
6
  RSpec::Core::RakeTask.new do |t|
10
7
  # t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
11
8
  # Put spec opts in a file named .rspec in root
12
9
  end
13
10
 
14
- begin
15
- require 'rocco'
16
- require 'rocco/tasks'
17
- require 'fileutils'
18
- require 'maruku'
19
- Rocco::make 'docs/'
20
- FileUtils.cp_r "docs/lib/", "/Users/hank/rails/dailycred/public/docs/ruby/", :verbose => true
21
- md = ""
22
- File.open("README.md", "r") do |infile|
23
- while (line = infile.gets)
24
- md += line
11
+ desc "run travis"
12
+ task :travis do
13
+ ["rake spec","ruby test/test_helper.rb"].each do |cmd|
14
+ puts "Starting to run #{cmd}..."
15
+ system("export DISPLAY=:99.0 && bundle exec #{cmd}")
16
+ raise "#{cmd} failed!" unless $?.exitstatus == 0
17
+ end
18
+ end
19
+
20
+ task :default => :travis
21
+
22
+ desc 'docs'
23
+ task :docs do
24
+ begin
25
+ require 'rocco'
26
+ require 'rocco/tasks'
27
+ require 'fileutils'
28
+ require 'maruku'
29
+ Rocco::make 'docs/'
30
+ FileUtils.cp_r "docs/lib/", "/Users/hank/rails/dailycred/public/docs/ruby/", :verbose => true
31
+ md = ""
32
+ File.open("README.md", "r") do |infile|
33
+ while (line = infile.gets)
34
+ md += line
35
+ end
25
36
  end
37
+ doc = Maruku.new(md)
38
+ File.open("/Users/hank/rails/dailycred/app/views/tags/docs/rubyonrails.html", 'w') {|f| f.write doc.to_html}
39
+ rescue LoadError
40
+ warn "#$! -- rocco tasks not loaded."
41
+ task :rocco
26
42
  end
27
- doc = Maruku.new(md)
28
- File.open("/Users/hank/rails/dailycred/app/views/tags/ruby.html", 'w') {|f| f.write doc.to_html}
29
- rescue LoadError
30
- warn "#$! -- rocco tasks not loaded."
31
- task :rocco
32
43
  end
@@ -9,5 +9,5 @@
9
9
  <%= link_to 'Log In', login_path() %>
10
10
  <br><%= link_to 'connect with facebook', connect_path(:identity_provider => :facebook) %>
11
11
  <br><%= link_to 'connect with google', connect_path(:identity_provider => :google) %>
12
- <br><%= link_to 'connect with twitter', current_user.connect_path(:twitter) %>
13
- <% end %>
12
+ <br><%= link_to 'connect with twitter',connect_path(:identity_provider => :twitter) %>
13
+ <% end %>
data/dailycred.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-=
2
+ require File.expand_path('../lib/dailycred/version', __FILE__)
2
3
 
3
4
  Gem::Specification.new do |gem|
4
5
  gem.authors = ["Hank Stoever"]
@@ -15,5 +16,5 @@ Gem::Specification.new do |gem|
15
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
17
  gem.name = "dailycred"
17
18
  gem.require_paths = ["lib"]
18
- gem.version = "0.1.4"
19
+ gem.version = Dailycred::VERSION
19
20
  end
@@ -1,5 +1,17 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  helper_method :current_user
3
+
4
+ private
5
+
6
+ # helper method for getting the current signed in user
7
+ def current_user
8
+ begin
9
+ @current_user || User.find(session[:user_id]) if session[:user_id]
10
+ rescue
11
+ nil
12
+ end
13
+ end
14
+ helper_method :current_user
3
15
  private
4
16
 
5
17
  # helper method for getting the current signed in user
@@ -1,10 +1,11 @@
1
1
  class PostsController < ApplicationController
2
+ before_filter :authenticate
2
3
  # GET /posts
3
4
  # GET /posts.json
4
-
5
- before_filter :authenticate
5
+
6
6
  def index
7
7
  @posts = Post.all
8
+ ap current_user.created.utc
8
9
 
9
10
  respond_to do |format|
10
11
  format.html # index.html.erb
@@ -9,6 +9,10 @@
9
9
  <body>
10
10
 
11
11
  <%= yield %>
12
+ <%= link_to 'login', connect_path %>
13
+ <% if !current_user.nil? %>
14
+ <%= debug current_user %>
15
+ <% end %>
12
16
 
13
17
  </body>
14
18
  </html>
@@ -1,13 +1,5 @@
1
- Rails.configuration.DAILYCRED_CLIENT_ID = "4133a23f-b9c3-47e4-8989-cfb30510079d"
2
- Rails.configuration.DAILYCRED_SECRET_KEY = "a1c21e72-98d8-47c2-9e9a-1e2dcd363b2f-f353b2af-1f51-416c-ad4c-59e70721dfab"
1
+ # Rails.configuration.DAILYCRED_CLIENT_ID = "4133a23f-b9c3-47e4-8989-cfb30510079d"
2
+ # Rails.configuration.DAILYCRED_SECRET_KEY = "a1c21e72-98d8-47c2-9e9a-1e2dcd363b2f-f353b2af-1f51-416c-ad4c-59e70721dfab"
3
3
 
4
- # configure where users should be redirected after authentication
5
-
6
- Rails.configuration.DAILYCRED_OPTIONS = {
7
- :client_options => {
8
- :site => 'http://ec2-72-44-40-55.compute-1.amazonaws.com:9000',
9
- :verbose => true
10
- }
11
- # :after_auth => '/hello', #after login
12
- # :after_unauth => '/goodbye' #after logout
13
- }
4
+ Rails.configuration.DAILYCRED_CLIENT_ID = "9be01b69-b9b9-4376-ab88-ace42033f241"
5
+ Rails.configuration.DAILYCRED_SECRET_KEY = "33e355d1-9e39-465e-b8d6-fcc734ce6e37-ee05ae3d-9bbe-4996-b6fd-04fa0341fc7f"
@@ -51,7 +51,7 @@ Dummy::Application.routes.draw do
51
51
 
52
52
  # You can have the root of your site routed with "root"
53
53
  # just remember to delete public/index.html.
54
- # root :to => 'welcome#index'
54
+ root :to => 'posts#index'
55
55
 
56
56
  # See how all your routes lay out with "rake routes"
57
57
 
@@ -0,0 +1,5 @@
1
+ class AddColumnToPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :posts, :created, :timestamp
4
+ end
5
+ end
@@ -5,20 +5,18 @@ class CreateUsers < ActiveRecord::Migration
5
5
  t.string :provider
6
6
  t.string :uid
7
7
  t.string :email
8
- t.integer :created
9
8
  t.string :username
10
9
  t.boolean :verified
11
10
  t.boolean :admin
12
11
  t.string :referred_by
13
12
  t.string :token
14
- t.text :facebook
13
+ t.string :access_token
15
14
  t.text :tags
16
15
  t.text :referred
17
- t.text :google
18
- t.text :twitter
19
- t.text :github
16
+ t.text :access_tokens
20
17
  t.boolean :subscribed
21
18
  t.string :display
19
+ t.text :identities
22
20
 
23
21
  t.timestamps
24
22
  end
@@ -26,20 +24,18 @@ class CreateUsers < ActiveRecord::Migration
26
24
  safe_column :users, :provider, :string
27
25
  safe_column :users, :uid, :string
28
26
  safe_column :users, :email, :string
29
- safe_column :users, :created, :integer
30
27
  safe_column :users, :username, :string
31
- safe_column :users, :verified, :booleanied
28
+ safe_column :users, :verified, :boolean
32
29
  safe_column :users, :admin, :boolean
33
30
  safe_column :users, :referred, :string
34
31
  safe_column :users, :token, :string
35
- safe_column :users, :facebook, :text
32
+ safe_column :users, :access_token, :string
36
33
  safe_column :users, :tags, :text
37
34
  safe_column :users, :referred, :text
38
- safe_column :users, :google, :text
39
- safe_column :users, :twitter, :text
40
- safe_column :users, :github, :text
35
+ safe_column :users, :access_tokens, :text
41
36
  safe_column :users, :display, :string
42
37
  safe_column :users, :subscribed, :boolean
38
+ safe_column :users, :identities, :text
43
39
  end
44
40
  end
45
41
 
@@ -0,0 +1,5 @@
1
+ class ChangeCreatedColumn < ActiveRecord::Migration
2
+ def change
3
+ change_column :users, :created, :datetime
4
+ end
5
+ end
data/dummy/db/schema.rb CHANGED
@@ -11,19 +11,20 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20121002192037) do
14
+ ActiveRecord::Schema.define(:version => 20121218205329) do
15
15
 
16
16
  create_table "posts", :force => true do |t|
17
17
  t.string "title"
18
18
  t.datetime "created_at", :null => false
19
19
  t.datetime "updated_at", :null => false
20
+ t.datetime "created"
20
21
  end
21
22
 
22
23
  create_table "users", :force => true do |t|
23
24
  t.string "provider"
24
25
  t.string "uid"
25
26
  t.string "email"
26
- t.integer "created", :limit => 8
27
+ t.datetime "created", :limit => 8
27
28
  t.string "username"
28
29
  t.boolean "verified"
29
30
  t.boolean "admin"
@@ -40,6 +41,8 @@ ActiveRecord::Schema.define(:version => 20121002192037) do
40
41
  t.string "display"
41
42
  t.boolean "subscribed"
42
43
  t.text "access_tokens"
44
+ t.string "access_token"
45
+ t.text "identities"
43
46
  end
44
47
 
45
48
  end
@@ -4,7 +4,7 @@ class PostsControllerTest < ActionController::TestCase
4
4
  setup do
5
5
  @post = posts(:one)
6
6
  @user = users(:basic)
7
- @controller.expects(:current_user).returns(@user)
7
+ @controller.stubs(:current_user).returns(@user)
8
8
  end
9
9
 
10
10
  test "should get index" do
@@ -1,12 +1,9 @@
1
1
  module ActsAsDailycred
2
2
  def acts_as_dailycred
3
- serialize :facebook, Hash
4
- serialize :twitter, Hash
5
- serialize :google, Hash
6
- serialize :github, Hash
7
3
  serialize :tags, Array
8
4
  serialize :referred, Array
9
5
  serialize :access_tokens, Hash
6
+ serialize :idenitities, Hash
10
7
 
11
8
  extend ActsAsDailycred::SingletonMethods
12
9
  include ActsAsDailycred::InstanceMethods
@@ -14,7 +11,7 @@ module ActsAsDailycred
14
11
  end
15
12
  module SingletonMethods
16
13
  def find_or_create_with_omniauth(model)
17
- @user = User.find_by_provider_and_uid(model[:provider], model[:uid]) || User.new
14
+ @user = User.find_by_provider_and_uid(model['provider'], model['uid']) || User.new
18
15
  @user.update_from_dailycred model[:info]
19
16
  @user
20
17
  end
@@ -40,20 +37,9 @@ module ActsAsDailycred
40
37
  end
41
38
  end
42
39
 
40
+ #deprecated, use @user.display
43
41
  def display_name
44
- display = self.email || ""
45
- p '1'
46
- if self.facebook != {}
47
- p '2'
48
- return self.facebook["name"]
49
- elsif self.google != {}
50
- p '3'
51
- return self.google["name"]
52
- elsif self.twitter != {}
53
- p '4'
54
- return "@"+self.twitter["screen_name"]
55
- end
56
- display
42
+ self.display
57
43
  end
58
44
 
59
45
  def referral_link url
@@ -64,8 +50,9 @@ module ActsAsDailycred
64
50
  end
65
51
 
66
52
  def update_from_dailycred dc
53
+ bad = ['updated_at', 'created_at']
67
54
  dc.each do |k,v|
68
- self[k] = v if self.respond_to?(k)
55
+ self[k] = v if self.respond_to?(k) and !bad.include?(k.to_s)
69
56
  end
70
57
  save!
71
58
  end
@@ -42,6 +42,7 @@ module Dailycred
42
42
 
43
43
  ActiveSupport.on_load(:action_controller) do
44
44
  include Dailycred::Helpers
45
+ helper Dailycred::Helpers
45
46
  end
46
47
  end
47
48
  end
@@ -25,27 +25,28 @@ module Dailycred
25
25
  end
26
26
 
27
27
  def login_path(params={})
28
- "/auth/dailycred"
28
+ connect_path params
29
29
  end
30
30
 
31
- def connect_path(params)
31
+ def connect_path(params={})
32
32
  url = "#{request.protocol}#{request.host_with_port}/auth/dailycred"
33
- p = []
33
+ params_array = []
34
34
  params.each do |k,v|
35
- p << "#{k}=#{v.to_s}"
35
+ params_array << "#{k}=#{v.to_s}"
36
36
  end
37
- url += "?" if p.size > 0
38
- url += p.join("&")
37
+ url += "?" if params_array.size > 0
38
+ url += params_array.join("&")
39
39
  end
40
40
 
41
41
  def connect_user provider, user=nil
42
42
  if user.nil?
43
43
  user = current_user
44
44
  end
45
- connect_path(access_token: user.token, identity_provider: provider)
45
+ connect_path(:access_token => user.token, :identity_provider => provider)
46
46
  end
47
47
 
48
48
  def redirect_to_auth opts={}
49
+ p 'redirecting to auth'
49
50
  conf = Rails.configuration.DAILYCRED_OPTIONS
50
51
  path = !conf[:after_auth].nil? ? conf[:after_auth] : dailycred_engine.auth_info_path
51
52
  redirect_to path, opts
@@ -15,7 +15,6 @@ module Dailycred
15
15
  def call(env)
16
16
  @env = env
17
17
  @status, @headers, @response = @app.call(env)
18
-
19
18
  if @headers["Content-Type"] =~ /text\/html|application\/xhtml\+xml/
20
19
  body = ""
21
20
  @response.each { |part| body << part }
@@ -41,6 +40,7 @@ module Dailycred
41
40
  window.dc_opts = {
42
41
  clientId: "#{@client_id}",
43
42
  home: "#{@opts[:url]}"
43
+ #{", type: \"#{@status.to_s}\"" if @status == 500 || @status == 400}
44
44
  };
45
45
  dc = document.createElement("script");
46
46
  url = dc_opts.home + "/public/js/cred.coffee";
@@ -1,63 +1,63 @@
1
- module Dailycred
2
- class User
3
- include ActiveModel::Validations
4
- include ActiveModel::Serialization
5
-
6
- validates_presence_of :email, :pass
7
-
8
- attr_accessor :client, :email, :pass, :authorized
9
-
10
- def initialize client, user = {}
11
- self.client = client
12
- self.authorized = false
13
- user.each do |k,v|
14
- self[k] = v if self.respond_to(k)
15
- end
16
- end
17
-
18
- def login
19
- if !self.valid?
20
- #it didn't work already, return false
21
- return false
22
- end
23
-
24
- response = JSON.parse client.login(self.to_hash)
25
- err_parser response
26
-
27
- return false if !self.valid?
28
- true
29
- end
30
-
31
- def to_hash
32
- {
33
- :email => self.email,
34
- :pass => self.pass
35
- }
36
- end
37
-
38
- private
39
-
40
- #response is a hash, which is
41
- #a json-parsed http response body
42
- def err_parser response
43
- if !response["worked"]
44
- self.authorized = false
45
- response["errors"].each do |err|
46
- attrib = err["attribute"]
47
- message = err["message"]
48
- if attrib == "form"
49
- self.errors.add_to_base message
50
- else
51
- if attrib == "user"
52
- self.errors.add :email, message
53
- elsif self.respond_to attrib
54
- self.errors.add attrib, message
55
- end
56
- end
57
- end
58
- end
59
- end
60
-
61
- end
62
-
63
- end
1
+ # module Dailycred
2
+ # class User
3
+ # include ActiveModel::Validations
4
+ # include ActiveModel::Serialization
5
+
6
+ # validates_presence_of :email, :pass
7
+
8
+ # attr_accessor :client, :email, :pass, :authorized
9
+
10
+ # def initialize client, user = {}
11
+ # self.client = client
12
+ # self.authorized = false
13
+ # user.each do |k,v|
14
+ # self[k] = v if self.respond_to(k)
15
+ # end
16
+ # end
17
+
18
+ # def login
19
+ # if !self.valid?
20
+ # #it didn't work already, return false
21
+ # return false
22
+ # end
23
+
24
+ # response = JSON.parse client.login(self.to_hash)
25
+ # err_parser response
26
+
27
+ # return false if !self.valid?
28
+ # true
29
+ # end
30
+
31
+ # def to_hash
32
+ # {
33
+ # :email => self.email,
34
+ # :pass => self.pass
35
+ # }
36
+ # end
37
+
38
+ # private
39
+
40
+ # #response is a hash, which is
41
+ # #a json-parsed http response body
42
+ # def err_parser response
43
+ # if !response["worked"]
44
+ # self.authorized = false
45
+ # response["errors"].each do |err|
46
+ # attrib = err["attribute"]
47
+ # message = err["message"]
48
+ # if attrib == "form"
49
+ # self.errors.add_to_base message
50
+ # else
51
+ # if attrib == "user"
52
+ # self.errors.add :email, message
53
+ # elsif self.respond_to attrib
54
+ # self.errors.add attrib, message
55
+ # end
56
+ # end
57
+ # end
58
+ # end
59
+ # end
60
+
61
+ # end
62
+
63
+ # end
@@ -0,0 +1,3 @@
1
+ module Dailycred
2
+ VERSION = "0.1.5"
3
+ end
@@ -34,9 +34,7 @@ class DailycredGenerator < Rails::Generators::Base
34
34
  # copy initializer
35
35
  template "omniauth.rb", "config/initializers/omniauth.rb"
36
36
  # get client info from login if they didnt specify info
37
- if @client_id == CLIENT_ID_DEFAULT
38
- get_info
39
- end
37
+ puts "Please manually configure your API keys in config/initializers/omniauth.rb"
40
38
  # application controller
41
39
  insert_into_file "app/controllers/application_controller.rb", APP_CONTROLLER_LINES, :after => /class ApplicationController\n|class ApplicationController .*\n/
42
40
  # add user_model
@@ -72,7 +70,7 @@ class DailycredGenerator < Rails::Generators::Base
72
70
  # url = "https://www.dailycred.com"
73
71
  # url = "http://localhost:9000"
74
72
  # staging server for a very short time
75
- url = "http://ec2-72-44-40-55.compute-1.amazonaws.com:9000"
73
+ url = "https://www.dailycred.com"
76
74
  connection = Faraday::Connection.new url, :ssl => ssl_opts
77
75
  params = {
78
76
  :login => email,
@@ -5,21 +5,18 @@ class CreateUsers < ActiveRecord::Migration
5
5
  t.string :provider
6
6
  t.string :uid
7
7
  t.string :email
8
- t.integer :created
9
8
  t.string :username
10
9
  t.boolean :verified
11
10
  t.boolean :admin
12
11
  t.string :referred_by
13
12
  t.string :token
14
- t.text :facebook
15
13
  t.text :tags
16
14
  t.text :referred
17
- t.text :google
18
- t.text :twitter
19
- t.text :github
20
15
  t.text :access_tokens
21
16
  t.boolean :subscribed
22
17
  t.string :display
18
+ t.text :identities
19
+ t.datetime :created
23
20
 
24
21
  t.timestamps
25
22
  end
@@ -27,21 +24,18 @@ class CreateUsers < ActiveRecord::Migration
27
24
  safe_column :users, :provider, :string
28
25
  safe_column :users, :uid, :string
29
26
  safe_column :users, :email, :string
30
- safe_column :users, :created, :integer
31
27
  safe_column :users, :username, :string
32
- safe_column :users, :verified, :booleanied
28
+ safe_column :users, :verified, :boolean
33
29
  safe_column :users, :admin, :boolean
34
30
  safe_column :users, :referred, :string
35
31
  safe_column :users, :token, :string
36
- safe_column :users, :facebook, :text
37
32
  safe_column :users, :tags, :text
38
33
  safe_column :users, :referred, :text
39
- safe_column :users, :google, :text
40
- safe_column :users, :twitter, :text
41
- safe_column :users, :github, :text
42
34
  safe_column :users, :access_tokens, :text
43
35
  safe_column :users, :display, :string
44
36
  safe_column :users, :subscribed, :boolean
37
+ safe_column :users, :identities, :text
38
+ safe_column :users, :created, :datetime
45
39
  end
46
40
  end
47
41
 
@@ -21,7 +21,7 @@ module OmniAuth
21
21
 
22
22
  option :authorize_options, OmniAuth::Strategies::Dailycred::AUTH_PARAMS
23
23
 
24
- uid { user['id'] }
24
+ uid { user['uid'] }
25
25
 
26
26
  info do
27
27
  user
@@ -69,6 +69,8 @@ module OmniAuth
69
69
  @duser[k][:access_token] = json["access_tokens"][k]
70
70
  end if !json["identities"].nil?
71
71
  pp @duser if options[:verbose]
72
+ created = json['created'] / 1000
73
+ @duser['created'] = DateTime.strptime(created.to_s, '%s')
72
74
  @duser.delete("id")
73
75
 
74
76
  @duser
data/spec/helper_spec.rb CHANGED
@@ -9,7 +9,7 @@ require 'dailycred'
9
9
 
10
10
  Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
11
11
 
12
- # require 'omniauth/strategies/dailycred_spec'
12
+ require 'omniauth/strategies/dailycred_spec'
13
13
 
14
14
  RSpec.configure do |config|
15
15
  config.include Rack::Test::Methods
@@ -17,13 +17,19 @@ describe OmniAuth::Strategies::Dailycred do
17
17
 
18
18
  it_should_behave_like 'an oauth2 strategy'
19
19
 
20
+ context "general" do
21
+ it "should be called dailycred" do
22
+ subject.options.name.should eq('dailycred')
23
+ end
24
+ end
25
+
20
26
 
21
27
  describe '#client' do
22
28
  it 'should have the correct dailycred site' do
23
29
  subject.client.site.should eq("https://www.dailycred.com")
24
30
  end
25
31
  it 'should have the correct authorization url' do
26
- subject.client.options[:authorize_url].should eq("/oauth/authorize")
32
+ subject.client.options[:authorize_url].should eq("/connect")
27
33
  end
28
34
 
29
35
  it 'should have the correct token url' do
@@ -1,4 +1,5 @@
1
1
  require 'rails/generators'
2
+ require 'test/unit'
2
3
  # require 'mocha'
3
4
  require_relative "../lib/generators/dailycred_generator.rb"
4
5
  class GeneratorTest < Rails::Generators::TestCase
@@ -44,41 +45,41 @@ class GeneratorTest < Rails::Generators::TestCase
44
45
  assert_credentials "aaa", "bbb"
45
46
  end
46
47
 
47
- test "generator works with login" do
48
- generator_class.any_instance.stubs(:get_input).returns(["localtest@dailycred.com","password"])
49
- test_generator
50
- assert_credentials "e92e20bf-e0a4-49b4-8a82-ff1b65d80017", "9adf81a8-ce97-4bcb-9c1f-c09f5fc7b6b8-0d1a4553-496d-450e-80fd-9e8d0552a920"
51
- end
48
+ # test "generator works with login" do
49
+ # generator_class.any_instance.stubs(:get_input).returns(["localtest@dailycred.com","password"])
50
+ # test_generator
51
+ # assert_credentials "e92e20bf-e0a4-49b4-8a82-ff1b65d80017", "9adf81a8-ce97-4bcb-9c1f-c09f5fc7b6b8-0d1a4553-496d-450e-80fd-9e8d0552a920"
52
+ # end
52
53
 
53
54
  private
54
55
 
55
56
  def test_generator args=[]
56
57
  run_generator args
57
58
  assert_file "config/initializers/omniauth.rb" do |config|
58
- assert_true config.include? 'Rails.configuration.DAILYCRED_CLIENT_ID ='
59
- assert_true config.include? 'Rails.configuration.DAILYCRED_SECRET_KEY ='
59
+ assert config.include? 'Rails.configuration.DAILYCRED_CLIENT_ID ='
60
+ assert config.include? 'Rails.configuration.DAILYCRED_SECRET_KEY ='
60
61
  end
61
62
 
62
63
  assert_file "config/routes.rb", /(#{Regexp.escape("mount Dailycred::Engine => '/auth', :as => 'dailycred_engine'")})/
63
64
 
64
65
  assert_file "app/models/user.rb" do |model|
65
- assert_true model.include? "acts_as_dailycred"
66
+ assert model.include? "acts_as_dailycred"
66
67
  end
67
68
 
68
69
  assert_file "app/controllers/application_controller.rb" do |controller|
69
70
  end
70
71
 
71
72
  assert_migration "db/migrate/create_users.rb" do |migration|
72
- assert_true migration.include? ":twitter"
73
- assert_true migration.include? ":github"
74
- assert_true migration.include? ":google"
73
+ assert migration.include? ":twitter"
74
+ assert migration.include? ":github"
75
+ assert migration.include? ":google"
75
76
  end
76
77
  end
77
78
 
78
79
  def assert_credentials client_id, client_secret
79
80
  assert_file "config/initializers/omniauth.rb" do |config|
80
- assert_true config.include? "Rails.configuration.DAILYCRED_CLIENT_ID = \"#{client_id}\""
81
- assert_true config.include? "Rails.configuration.DAILYCRED_SECRET_KEY = \"#{client_secret}\""
81
+ assert config.include? "Rails.configuration.DAILYCRED_CLIENT_ID = \"#{client_id}\""
82
+ assert config.include? "Rails.configuration.DAILYCRED_SECRET_KEY = \"#{client_secret}\""
82
83
  end
83
84
  end
84
85
 
data/test/test_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'test/unit'
2
-
2
+ # require 'mocha/setup'
3
3
 
4
4
 
5
5
  require_relative './generator_test.rb'
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
4
+ version: 0.1.5
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-10-17 00:00:00.000000000 Z
12
+ date: 2012-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
@@ -51,6 +51,7 @@ extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
53
  - .gitignore
54
+ - .travis.yml
54
55
  - Gemfile
55
56
  - Guardfile
56
57
  - LICENSE
@@ -119,9 +120,11 @@ files:
119
120
  - dummy/config/initializers/wrap_parameters.rb
120
121
  - dummy/config/locales/en.yml
121
122
  - dummy/config/routes.rb
122
- - dummy/db/migrate/20120925172903_create_users.rb
123
123
  - dummy/db/migrate/20120926012555_create_posts.rb
124
124
  - dummy/db/migrate/20121002192037_update_users_2.rb
125
+ - dummy/db/migrate/20121108192739_add_column_to_posts.rb
126
+ - dummy/db/migrate/20121218124721_create_users.rb
127
+ - dummy/db/migrate/20121218205329_change_created_column.rb
125
128
  - dummy/db/schema.rb
126
129
  - dummy/db/seeds.rb
127
130
  - dummy/lib/assets/.gitkeep
@@ -131,7 +134,6 @@ files:
131
134
  - dummy/public/422.html
132
135
  - dummy/public/500.html
133
136
  - dummy/public/favicon.ico
134
- - dummy/public/index.html
135
137
  - dummy/public/robots.txt
136
138
  - dummy/script/rails
137
139
  - dummy/test/fixtures/.gitkeep
@@ -157,6 +159,7 @@ files:
157
159
  - lib/dailycred/middleware.rb
158
160
  - lib/dailycred/tests_helper.rb
159
161
  - lib/dailycred/user.rb
162
+ - lib/dailycred/version.rb
160
163
  - lib/generators/USAGE
161
164
  - lib/generators/dailycred_generator.rb
162
165
  - lib/generators/templates/info.html.erb
@@ -185,12 +188,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
188
  - - ! '>='
186
189
  - !ruby/object:Gem::Version
187
190
  version: '0'
191
+ segments:
192
+ - 0
193
+ hash: 3809456229440668056
188
194
  required_rubygems_version: !ruby/object:Gem::Requirement
189
195
  none: false
190
196
  requirements:
191
197
  - - ! '>='
192
198
  - !ruby/object:Gem::Version
193
199
  version: '0'
200
+ segments:
201
+ - 0
202
+ hash: 3809456229440668056
194
203
  requirements: []
195
204
  rubyforge_project:
196
205
  rubygems_version: 1.8.24
@@ -204,4 +213,3 @@ test_files:
204
213
  - spec/support/shared_examples.rb
205
214
  - test/generator_test.rb
206
215
  - test/test_helper.rb
207
- has_rdoc:
@@ -1,241 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Ruby on Rails: Welcome aboard</title>
5
- <style type="text/css" media="screen">
6
- body {
7
- margin: 0;
8
- margin-bottom: 25px;
9
- padding: 0;
10
- background-color: #f0f0f0;
11
- font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
12
- font-size: 13px;
13
- color: #333;
14
- }
15
-
16
- h1 {
17
- font-size: 28px;
18
- color: #000;
19
- }
20
-
21
- a {color: #03c}
22
- a:hover {
23
- background-color: #03c;
24
- color: white;
25
- text-decoration: none;
26
- }
27
-
28
-
29
- #page {
30
- background-color: #f0f0f0;
31
- width: 750px;
32
- margin: 0;
33
- margin-left: auto;
34
- margin-right: auto;
35
- }
36
-
37
- #content {
38
- float: left;
39
- background-color: white;
40
- border: 3px solid #aaa;
41
- border-top: none;
42
- padding: 25px;
43
- width: 500px;
44
- }
45
-
46
- #sidebar {
47
- float: right;
48
- width: 175px;
49
- }
50
-
51
- #footer {
52
- clear: both;
53
- }
54
-
55
- #header, #about, #getting-started {
56
- padding-left: 75px;
57
- padding-right: 30px;
58
- }
59
-
60
-
61
- #header {
62
- background-image: url("assets/rails.png");
63
- background-repeat: no-repeat;
64
- background-position: top left;
65
- height: 64px;
66
- }
67
- #header h1, #header h2 {margin: 0}
68
- #header h2 {
69
- color: #888;
70
- font-weight: normal;
71
- font-size: 16px;
72
- }
73
-
74
-
75
- #about h3 {
76
- margin: 0;
77
- margin-bottom: 10px;
78
- font-size: 14px;
79
- }
80
-
81
- #about-content {
82
- background-color: #ffd;
83
- border: 1px solid #fc0;
84
- margin-left: -55px;
85
- margin-right: -10px;
86
- }
87
- #about-content table {
88
- margin-top: 10px;
89
- margin-bottom: 10px;
90
- font-size: 11px;
91
- border-collapse: collapse;
92
- }
93
- #about-content td {
94
- padding: 10px;
95
- padding-top: 3px;
96
- padding-bottom: 3px;
97
- }
98
- #about-content td.name {color: #555}
99
- #about-content td.value {color: #000}
100
-
101
- #about-content ul {
102
- padding: 0;
103
- list-style-type: none;
104
- }
105
-
106
- #about-content.failure {
107
- background-color: #fcc;
108
- border: 1px solid #f00;
109
- }
110
- #about-content.failure p {
111
- margin: 0;
112
- padding: 10px;
113
- }
114
-
115
-
116
- #getting-started {
117
- border-top: 1px solid #ccc;
118
- margin-top: 25px;
119
- padding-top: 15px;
120
- }
121
- #getting-started h1 {
122
- margin: 0;
123
- font-size: 20px;
124
- }
125
- #getting-started h2 {
126
- margin: 0;
127
- font-size: 14px;
128
- font-weight: normal;
129
- color: #333;
130
- margin-bottom: 25px;
131
- }
132
- #getting-started ol {
133
- margin-left: 0;
134
- padding-left: 0;
135
- }
136
- #getting-started li {
137
- font-size: 18px;
138
- color: #888;
139
- margin-bottom: 25px;
140
- }
141
- #getting-started li h2 {
142
- margin: 0;
143
- font-weight: normal;
144
- font-size: 18px;
145
- color: #333;
146
- }
147
- #getting-started li p {
148
- color: #555;
149
- font-size: 13px;
150
- }
151
-
152
-
153
- #sidebar ul {
154
- margin-left: 0;
155
- padding-left: 0;
156
- }
157
- #sidebar ul h3 {
158
- margin-top: 25px;
159
- font-size: 16px;
160
- padding-bottom: 10px;
161
- border-bottom: 1px solid #ccc;
162
- }
163
- #sidebar li {
164
- list-style-type: none;
165
- }
166
- #sidebar ul.links li {
167
- margin-bottom: 5px;
168
- }
169
-
170
- .filename {
171
- font-style: italic;
172
- }
173
- </style>
174
- <script type="text/javascript">
175
- function about() {
176
- info = document.getElementById('about-content');
177
- if (window.XMLHttpRequest)
178
- { xhr = new XMLHttpRequest(); }
179
- else
180
- { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
181
- xhr.open("GET","rails/info/properties",false);
182
- xhr.send("");
183
- info.innerHTML = xhr.responseText;
184
- info.style.display = 'block'
185
- }
186
- </script>
187
- </head>
188
- <body>
189
- <div id="page">
190
- <div id="sidebar">
191
- <ul id="sidebar-items">
192
- <li>
193
- <h3>Browse the documentation</h3>
194
- <ul class="links">
195
- <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
196
- <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
197
- <li><a href="http://www.ruby-doc.org/core/">Ruby core</a></li>
198
- <li><a href="http://www.ruby-doc.org/stdlib/">Ruby standard library</a></li>
199
- </ul>
200
- </li>
201
- </ul>
202
- </div>
203
-
204
- <div id="content">
205
- <div id="header">
206
- <h1>Welcome aboard</h1>
207
- <h2>You&rsquo;re riding Ruby on Rails!</h2>
208
- </div>
209
-
210
- <div id="about">
211
- <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
212
- <div id="about-content" style="display: none"></div>
213
- </div>
214
-
215
- <div id="getting-started">
216
- <h1>Getting started</h1>
217
- <h2>Here&rsquo;s how to get rolling:</h2>
218
-
219
- <ol>
220
- <li>
221
- <h2>Use <code>rails generate</code> to create your models and controllers</h2>
222
- <p>To see all available options, run it without parameters.</p>
223
- </li>
224
-
225
- <li>
226
- <h2>Set up a default route and remove <span class="filename">public/index.html</span></h2>
227
- <p>Routes are set up in <span class="filename">config/routes.rb</span>.</p>
228
- </li>
229
-
230
- <li>
231
- <h2>Create your database</h2>
232
- <p>Run <code>rake db:create</code> to create your database. If you're not using SQLite (the default), edit <span class="filename">config/database.yml</span> with your username and password.</p>
233
- </li>
234
- </ol>
235
- </div>
236
- </div>
237
-
238
- <div id="footer">&nbsp;</div>
239
- </div>
240
- </body>
241
- </html>