rails-dribbble-oauth 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/Gemfile +14 -0
- data/MIT-LICENSE +20 -0
- data/README.md +121 -0
- data/app/controllers/.keep +0 -0
- data/app/controllers/main_controller.rb +64 -0
- data/bin/rails +12 -0
- data/config/routes.rb +5 -0
- data/lib/rails-dribbble-oauth.rb +11 -0
- data/lib/rails-dribbble-oauth/engine.rb +7 -0
- data/lib/rails-dribbble-oauth/version.rb +3 -0
- data/rails-dribbble-oauth.gemspec +24 -0
- data/screenshots/callback_screenshot.png +0 -0
- data/screenshots/oauth_request.png +0 -0
- data/spec/controllers/main_controller_spec.rb +84 -0
- data/spec/rails_helper.rb +57 -0
- data/spec/routing/routing_spec.rb +18 -0
- data/spec/spec_helper.rb +86 -0
- metadata +74 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d55b994a463bf26f1b764f81d259641d586c3d8f
|
4
|
+
data.tar.gz: f27fe028bc953fc0a5f68dae31f332ccbe5775be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b24eecdad9a17ba8e3336f3eb43db926d0303e3b360176f23a5445002b5862d85e3bca9661f90253acfdca611b5a6a1387da9c405fc9cc7f0c0d861d9a3706e1
|
7
|
+
data.tar.gz: ab634acfed78c3c3802df37a329b937c6d7343886123bafce793e49d135b5a71e9ec838120e721470c81b63ee33ab8bff80210ad53212ce44906402562b71d83
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in rails-dribbble-oauth.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use a debugger
|
14
|
+
# gem 'byebug', group: [:development, :test]
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Esther Leytush
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# rails-dribbble-oauth
|
2
|
+
A lightweight engine gem/plugin with no dependencies for authenticating users through Dribbble. Provides Dribble oauth calls to authenticate a given user, and receive back user's Dribbble information.
|
3
|
+
|
4
|
+
<hr>
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rails-dribbble-oauth'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
```bash
|
15
|
+
$ bundle
|
16
|
+
```
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
```bash
|
20
|
+
$ gem install rails-dribbble-oauth
|
21
|
+
```
|
22
|
+
|
23
|
+
### Register your application with Dribbble and setup the callback
|
24
|
+
|
25
|
+
`rails-dribbble-oauth` adds routes to your applicationupon installation, visible via `rake routes`. The route setup is `[your root app]/dribbble/*`, where `*` is one of three possibilities: `request`, `callback`, and `information`.
|
26
|
+
|
27
|
+
To get started, register your application with Dribbble.
|
28
|
+
* Make a user account if you do not already have one.
|
29
|
+
* Navigate to [dribbble.com/account/applications](https://dribbble.com/account/applications) to create your application's account.
|
30
|
+
* On the bottom of the page, click [Register a new application](https://dribbble.com/account/applications/new).
|
31
|
+
* Edit the **Website URL** and **Callback URL** portions. Include the **callback** route defined by the gem. This means your callback URL will be `http://[your root application URL]/dribbble/callback`:
|
32
|
+
|
33
|
+
![callback screenshot](screenshots/callback_screenshot.png)
|
34
|
+
|
35
|
+
As soon as your application is registered, you will see your **Client ID**, **Client Secret**, and **Client Access Token** below on the same page. Copy the **Client ID** and **Client Secret** values: you'll need to echo those into your application's runtime environment in order to use the gem.
|
36
|
+
|
37
|
+
### Echo environment variables from Dribbble
|
38
|
+
Navigate to your application's environment shell. Run the following commands:
|
39
|
+
|
40
|
+
```bash
|
41
|
+
export DRIBBBLE_CLIENT_ID="[your application's Client ID]"
|
42
|
+
export DRIBBBLE_CLIENT_SECRET="[your application's Client Secret]"
|
43
|
+
```
|
44
|
+
|
45
|
+
Note: these environment variables must be named in this specific format.
|
46
|
+
|
47
|
+
### Build links in your root application
|
48
|
+
You're now ready to build links in your root application. Navigate to the appropriate views and build your links using the `dribbble_request_path`, passing it a user_id parameter:
|
49
|
+
```
|
50
|
+
<%= link_to "Dribbble authentication request", dribbble_request_path(user_id: @user.id) %>
|
51
|
+
```
|
52
|
+
|
53
|
+
If your requesting user does not have an ID yet--such as if you want to authorize/authenticate users via Dribbble--this service will still work if it gets a `nil` value for `user_id`.
|
54
|
+
|
55
|
+
### Get back user information from Dribbble
|
56
|
+
Add this line to your `ApplicationController`:
|
57
|
+
|
58
|
+
```
|
59
|
+
include RailsDribbbleOauth
|
60
|
+
```
|
61
|
+
|
62
|
+
Setup a new action in your `UserController`: `add_dribbble_info`. This action will be triggered once the Dribbble oauth request returns with information about the requesting user.
|
63
|
+
|
64
|
+
#### Program flow:
|
65
|
+
1. User clicks your link: `[your root app]/dribbble/request`.
|
66
|
+
2. User is served this page:
|
67
|
+
|
68
|
+
![oauth request](screenshots/oauth_request.png)
|
69
|
+
|
70
|
+
3. User clicks *Authorize*.
|
71
|
+
4. `rails-dribbble-oauth` handles getting user's info from Dribbble.
|
72
|
+
4. `rails-dribbble-oauth` redirects to your root application's `[base app]/users/add_dribbble_info` route with params containing the requesting user's information, such as in the following example. Note that `params[:user_id]` corresponds to your requesting user's ID in your application.
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
{ "status"=>"200 OK",
|
76
|
+
"success"=>"true",
|
77
|
+
"user_id"=>"1", # this is nil in the case of there not being a main app user registered initially
|
78
|
+
"user_data"=>{
|
79
|
+
"avatar_url"=>"https://d13yacurqjgara.cloudfront.net/assets/avatar-default-aa2eab7684294781f93bc99ad394a0eb3249c5768c21390163c9f55ea8ef83a4.gif",
|
80
|
+
"bio"=>"",
|
81
|
+
"buckets_count"=>"0",
|
82
|
+
"buckets_url"=>"https://api.dribbble.com/v1/users/1204942/buckets",
|
83
|
+
"can_upload_shot"=>"false",
|
84
|
+
"comments_received_count"=>"0",
|
85
|
+
"created_at"=>"2016-06-03T14:11:25Z",
|
86
|
+
"followers_count"=>"0",
|
87
|
+
"followers_url"=>"https://api.dribbble.com/v1/users/1204942/followers",
|
88
|
+
"following_url"=>"https://api.dribbble.com/v1/users/1204942/following",
|
89
|
+
"followings_count"=>"0",
|
90
|
+
"html_url"=>"https://dribbble.com/mindpl_ace",
|
91
|
+
"id"=>"[some id]",
|
92
|
+
"likes_count"=>"0",
|
93
|
+
"likes_received_count"=>"0",
|
94
|
+
"likes_url"=>"https://api.dribbble.com/v1/users/1204942/likes",
|
95
|
+
"location"=>"",
|
96
|
+
"name"=>"Esther Leytush",
|
97
|
+
"pro"=>"false",
|
98
|
+
"projects_count"=>"0",
|
99
|
+
"projects_url"=>"https://api.dribbble.com/v1/users/1204942/projects",
|
100
|
+
"rebounds_received_count"=>"0",
|
101
|
+
"shots_count"=>"0",
|
102
|
+
"shots_url"=>"https://api.dribbble.com/v1/users/1204942/shots",
|
103
|
+
"teams_count"=>"0",
|
104
|
+
"teams_url"=>"https://api.dribbble.com/v1/users/1204942/teams",
|
105
|
+
"type"=>"User",
|
106
|
+
"updated_at"=>"2016-06-03T14:11:50Z",
|
107
|
+
"username"=>"mindpl_ace"}
|
108
|
+
}
|
109
|
+
```
|
110
|
+
|
111
|
+
<hr>
|
112
|
+
|
113
|
+
## Contributing
|
114
|
+
Please make PRs for any aspect of this service that you feel is lacking. You can also check out [open issues](https://github.com/mindplace/rails-dribbble-oauth/issues).
|
115
|
+
|
116
|
+
I appreciate any feedback, help, and contributions!
|
117
|
+
|
118
|
+
<hr>
|
119
|
+
|
120
|
+
## License
|
121
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
File without changes
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class MainController < ::ApplicationController
|
2
|
+
include RailsDribbbleOauth
|
3
|
+
|
4
|
+
def oauth_request
|
5
|
+
# sets current dribbble user session, cleared on callback
|
6
|
+
# does not rely on main app to set a current_user
|
7
|
+
id = request.env["QUERY_STRING"].split("=").last.to_i
|
8
|
+
session[:current_dribbble_user] = id > 0 ? id : nil
|
9
|
+
|
10
|
+
# redirect to https://dribbble.com/oauth/authorize
|
11
|
+
dribbble = "https://dribbble.com/oauth/authorize"
|
12
|
+
|
13
|
+
# in order for params to be built, you must have set environment variables:
|
14
|
+
# get your DRIBBBLE_CLIENT_ID and DRIBBBLE_CLIENT_SECRET from
|
15
|
+
# your Dribbble account directly: https://dribbble.com/account/applications/
|
16
|
+
params = {"client_id" => ENV["DRIBBBLE_CLIENT_ID"]}
|
17
|
+
|
18
|
+
# makes first request to Dribbble with your Client ID
|
19
|
+
redirect_to "#{dribbble}?#{params.to_query}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def callback
|
23
|
+
# get back the code to make next API call
|
24
|
+
params = {
|
25
|
+
"client_id" => ENV["DRIBBBLE_CLIENT_ID"],
|
26
|
+
"client_secret" => ENV["DRIBBBLE_CLIENT_SECRET"],
|
27
|
+
"code" => request.env["QUERY_STRING"][5..-1],
|
28
|
+
"button1" => "Submit"
|
29
|
+
}
|
30
|
+
|
31
|
+
# use code to request access token
|
32
|
+
uri = URI.parse("https://dribbble.com/oauth/token")
|
33
|
+
request = Net::HTTP.post_form(uri, params)
|
34
|
+
token = JSON.parse(request.response.body)["access_token"]
|
35
|
+
|
36
|
+
# use access token to get access to the API
|
37
|
+
params = {"access_token" => token}
|
38
|
+
uri = URI.parse("https://api.dribbble.com/v1/user")
|
39
|
+
uri.query = URI.encode_www_form(params)
|
40
|
+
response = Net::HTTP.get(uri)
|
41
|
+
|
42
|
+
data = {
|
43
|
+
success: true,
|
44
|
+
status: "200 OK",
|
45
|
+
message: nil,
|
46
|
+
user_id: current_dribbble_user,
|
47
|
+
user_data: nil
|
48
|
+
}
|
49
|
+
|
50
|
+
response = JSON.parse(response)
|
51
|
+
|
52
|
+
if request.code != "200"
|
53
|
+
# if there was some sort of failure
|
54
|
+
data[:success] = false
|
55
|
+
data[:status] = "204 No Content"
|
56
|
+
data[:message] = "No user data returned from Dribbble. Reason provided by Dribbble: '#{response["message"]}'"
|
57
|
+
else
|
58
|
+
data[:user_data] = response
|
59
|
+
end
|
60
|
+
|
61
|
+
clear_dribbble_user
|
62
|
+
redirect_to dribbble_information_path(data)
|
63
|
+
end
|
64
|
+
end
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/rails-dribbble-oauth/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
get 'dribbble/request', to: 'main#oauth_request', as: "dribbble_request"
|
3
|
+
get 'dribbble/callback', to: 'main#callback', as: "dribbble_callback"
|
4
|
+
get 'dribbble/information', to: 'users#add_dribbble_info', as: "dribbble_information"
|
5
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "rails-dribbble-oauth/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "rails-dribbble-oauth"
|
6
|
+
s.version = RailsDribbbleOauth::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Esther Leytush"]
|
9
|
+
s.email = ["eleytush@gmail.com"]
|
10
|
+
s.summary = "A Rails engine gem for authenticating users through Dribbble, with no dependencies."
|
11
|
+
s.homepage = "https://github.com/mindplace/rails-dribbble-oauth"
|
12
|
+
s.license = "MIT"
|
13
|
+
|
14
|
+
s.add_dependency "rails", "~> 4.0", "< 6"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
|
18
|
+
# Production and testing:
|
19
|
+
s.add_development_dependency 'pry', ['>= 0.10.4', '< 2.0']
|
20
|
+
s.add_development_dependency 'bundler', ['>= 1.0', '< 2.0']
|
21
|
+
s.add_development_dependency 'rspec-rails', ['>= 3.5', '< 4.0']
|
22
|
+
s.add_development_dependency 'capybara', ['>= 2.7', '< 3.0']
|
23
|
+
s.add_development_dependency 'factory_girl_rails', ['>= 4.4', '< 6.0']
|
24
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe MainController do
|
4
|
+
|
5
|
+
describe "GET #oauth_request" do
|
6
|
+
it "sets the correct session[:current_dribbble_user] if an id is passed" do
|
7
|
+
get :oauth_request, { id: 10 }
|
8
|
+
expect(request.session[:current_dribbble_user]).to eq(10)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "sets session[:current_dribbble_user] to nil if an id is not passed" do
|
12
|
+
get :oauth_request
|
13
|
+
expect(request.session[:current_dribbble_user]).to eq(nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "redirects user to Dribbble.com with correct params" do
|
17
|
+
if !ENV["DRIBBBLE_CLIENT_ID"]
|
18
|
+
ENV["DRIBBBLE_CLIENT_ID"] = "1"
|
19
|
+
end
|
20
|
+
get :oauth_request
|
21
|
+
expect(response).to redirect_to("https://dribbble.com/oauth/authorize?client_id=#{ENV["DRIBBBLE_CLIENT_ID"]}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "GET #callback" do
|
26
|
+
# these tests will fail if environment variables aren't echoed
|
27
|
+
|
28
|
+
# TODO: I have no idea how to build these tests to dynamically make the #oauth_request call each time yet trigger the #callback method myself
|
29
|
+
|
30
|
+
# before :each do
|
31
|
+
# get :callback, { code: "c019cc67fc53a58419ce1180669de2c7c10c9013ce808e0641fa3defd88b59f8"} # code example
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Try this: https://github.com/vcr/vcr
|
35
|
+
|
36
|
+
it "makes a call to API get access token"
|
37
|
+
it "uses access token to get access to main API"
|
38
|
+
it "prepares user information with user_id if main app already has this user registered"
|
39
|
+
it "prepares user information with user_id = nil if main app does not have this user registered"
|
40
|
+
it "calls clear_dribbble_user"
|
41
|
+
it "redirects to dribble_info_path with user information"
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
# These are being tested here because they are triggered by MainController methods
|
46
|
+
|
47
|
+
describe "current_dribbble_user" do
|
48
|
+
include RailsDribbbleOauth
|
49
|
+
|
50
|
+
it "returns id corresponding to user in database if user was present when main#oauth_request was called" do
|
51
|
+
user = User.create(email: "test@test.com", password: "password", first_name: "test_first", last_name: "test_last")
|
52
|
+
|
53
|
+
get :oauth_request, { id: user.id }
|
54
|
+
expect(current_dribbble_user.id).to eq(user.id)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns nil if there is no current_dribbble_user" do
|
58
|
+
user = User.create(email: "test@test.com", password: "password", first_name: "test_first", last_name: "test_last")
|
59
|
+
|
60
|
+
get :oauth_request
|
61
|
+
expect{ current_dribbble_user.id }.to raise_error(NoMethodError)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "clear_dribbble_user" do
|
66
|
+
include RailsDribbbleOauth
|
67
|
+
|
68
|
+
it "returns nil when called" do
|
69
|
+
user = User.create(email: "test@test.com", password: "password", first_name: "test_first", last_name: "test_last")
|
70
|
+
|
71
|
+
get :oauth_request, { id: user.id }
|
72
|
+
clear_dribbble_user
|
73
|
+
expect{ current_dribbble_user.id }.to raise_error(NoMethodError)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "sets session[:current_dribbble_user] to nil" do
|
77
|
+
user = User.create(email: "test@test.com", password: "password", first_name: "test_first", last_name: "test_last")
|
78
|
+
|
79
|
+
get :oauth_request, { id: user.id }
|
80
|
+
clear_dribbble_user
|
81
|
+
expect(session[:current_dribbble_user]).to eq(nil)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV['RAILS_ENV'] ||= 'test'
|
3
|
+
require File.expand_path('../test-app/config/environment', __FILE__)
|
4
|
+
require 'spec_helper'
|
5
|
+
# Prevent database truncation if the environment is production
|
6
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
7
|
+
require 'rspec/rails'
|
8
|
+
require 'capybara/rails'
|
9
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
10
|
+
|
11
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
12
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
13
|
+
# run as spec files by default. This means that files in spec/support that end
|
14
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
15
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
16
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
17
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
18
|
+
#
|
19
|
+
# The following line is provided for convenience purposes. It has the downside
|
20
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
21
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
22
|
+
# require only the support files necessary.
|
23
|
+
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
24
|
+
|
25
|
+
# Checks for pending migration and applies them before tests are run.
|
26
|
+
# If you are not using ActiveRecord, you can remove this line.
|
27
|
+
ActiveRecord::Migration.maintain_test_schema!
|
28
|
+
|
29
|
+
RSpec.configure do |config|
|
30
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
31
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
32
|
+
|
33
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
34
|
+
# examples within a transaction, remove the following line or assign false
|
35
|
+
# instead of true.
|
36
|
+
config.use_transactional_fixtures = true
|
37
|
+
|
38
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
39
|
+
# based on their file location, for example enabling you to call `get` and
|
40
|
+
# `post` in specs under `spec/controllers`.
|
41
|
+
#
|
42
|
+
# You can disable this behaviour by removing the line below, and instead
|
43
|
+
# explicitly tag your specs with their type, e.g.:
|
44
|
+
#
|
45
|
+
# RSpec.describe UsersController, :type => :controller do
|
46
|
+
# # ...
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# The different available types are documented in the features, such as in
|
50
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
51
|
+
config.infer_spec_type_from_file_location!
|
52
|
+
|
53
|
+
# Filter lines from Rails gems in backtraces.
|
54
|
+
config.filter_rails_from_backtrace!
|
55
|
+
# arbitrary gems may also be filtered via:
|
56
|
+
# config.filter_gems_from_backtrace("gem name")
|
57
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe MainController, :type => :routing do
|
4
|
+
describe "routing" do
|
5
|
+
|
6
|
+
it "routes to #oauth_request" do
|
7
|
+
expect(:get => "/dribbble/request").to route_to("main#oauth_request")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "routes to #callback" do
|
11
|
+
expect(:get => "/dribbble/callback").to route_to("main#callback")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "routes away to UserController for #dribbble_information" do
|
15
|
+
expect(:get => "/dribbble/information").to route_to("users#add_dribbble_info")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
45
|
+
=begin
|
46
|
+
# These two settings work together to allow you to limit a spec run
|
47
|
+
# to individual examples or groups you care about by tagging them with
|
48
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
+
# get run.
|
50
|
+
config.filter_run :focus
|
51
|
+
config.run_all_when_everything_filtered = true
|
52
|
+
# Allows RSpec to persist some state between runs in order to support
|
53
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
54
|
+
# you configure your source control system to ignore this file.
|
55
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
56
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
57
|
+
# recommended. For more details, see:
|
58
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
59
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
60
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
61
|
+
config.disable_monkey_patching!
|
62
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
63
|
+
# file, and it's useful to allow more verbose output when running an
|
64
|
+
# individual spec file.
|
65
|
+
if config.files_to_run.one?
|
66
|
+
# Use the documentation formatter for detailed output,
|
67
|
+
# unless a formatter has already been configured
|
68
|
+
# (e.g. via a command-line flag).
|
69
|
+
config.default_formatter = 'doc'
|
70
|
+
end
|
71
|
+
# Print the 10 slowest examples and example groups at the
|
72
|
+
# end of the spec run, to help surface which specs are running
|
73
|
+
# particularly slow.
|
74
|
+
config.profile_examples = 10
|
75
|
+
# Run specs in random order to surface order dependencies. If you find an
|
76
|
+
# order dependency and want to debug it, you can fix the order by providing
|
77
|
+
# the seed, which is printed after each run.
|
78
|
+
# --seed 1234
|
79
|
+
config.order = :random
|
80
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
81
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
82
|
+
# test failures related to randomization by passing the same `--seed` value
|
83
|
+
# as the one that triggered the failure.
|
84
|
+
Kernel.srand config.seed
|
85
|
+
=end
|
86
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-dribbble-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esther Leytush
|
@@ -14,7 +14,7 @@ dependencies:
|
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
20
|
- - "<"
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '4.0'
|
30
30
|
- - "<"
|
@@ -34,79 +34,128 @@ dependencies:
|
|
34
34
|
name: pry
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 0.10.4
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.0'
|
40
43
|
type: :development
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
|
-
- - "
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.10.4
|
50
|
+
- - "<"
|
45
51
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
52
|
+
version: '2.0'
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: bundler
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
50
56
|
requirements:
|
51
|
-
- - "
|
57
|
+
- - ">="
|
52
58
|
- !ruby/object:Gem::Version
|
53
59
|
version: '1.0'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2.0'
|
54
63
|
type: :development
|
55
64
|
prerelease: false
|
56
65
|
version_requirements: !ruby/object:Gem::Requirement
|
57
66
|
requirements:
|
58
|
-
- - "
|
67
|
+
- - ">="
|
59
68
|
- !ruby/object:Gem::Version
|
60
69
|
version: '1.0'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '2.0'
|
61
73
|
- !ruby/object:Gem::Dependency
|
62
74
|
name: rspec-rails
|
63
75
|
requirement: !ruby/object:Gem::Requirement
|
64
76
|
requirements:
|
65
|
-
- - "
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '3.5'
|
80
|
+
- - "<"
|
66
81
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
82
|
+
version: '4.0'
|
68
83
|
type: :development
|
69
84
|
prerelease: false
|
70
85
|
version_requirements: !ruby/object:Gem::Requirement
|
71
86
|
requirements:
|
72
|
-
- - "
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.5'
|
90
|
+
- - "<"
|
73
91
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
92
|
+
version: '4.0'
|
75
93
|
- !ruby/object:Gem::Dependency
|
76
94
|
name: capybara
|
77
95
|
requirement: !ruby/object:Gem::Requirement
|
78
96
|
requirements:
|
79
|
-
- - "
|
97
|
+
- - ">="
|
80
98
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
99
|
+
version: '2.7'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.0'
|
82
103
|
type: :development
|
83
104
|
prerelease: false
|
84
105
|
version_requirements: !ruby/object:Gem::Requirement
|
85
106
|
requirements:
|
86
|
-
- - "
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.7'
|
110
|
+
- - "<"
|
87
111
|
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
112
|
+
version: '3.0'
|
89
113
|
- !ruby/object:Gem::Dependency
|
90
114
|
name: factory_girl_rails
|
91
115
|
requirement: !ruby/object:Gem::Requirement
|
92
116
|
requirements:
|
93
|
-
- - "
|
117
|
+
- - ">="
|
94
118
|
- !ruby/object:Gem::Version
|
95
|
-
version: 4.4
|
119
|
+
version: '4.4'
|
120
|
+
- - "<"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '6.0'
|
96
123
|
type: :development
|
97
124
|
prerelease: false
|
98
125
|
version_requirements: !ruby/object:Gem::Requirement
|
99
126
|
requirements:
|
100
|
-
- - "
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '4.4'
|
130
|
+
- - "<"
|
101
131
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
132
|
+
version: '6.0'
|
103
133
|
description:
|
104
134
|
email:
|
105
135
|
- eleytush@gmail.com
|
106
136
|
executables: []
|
107
137
|
extensions: []
|
108
138
|
extra_rdoc_files: []
|
109
|
-
files:
|
139
|
+
files:
|
140
|
+
- ".gitignore"
|
141
|
+
- Gemfile
|
142
|
+
- Gemfile.lock
|
143
|
+
- MIT-LICENSE
|
144
|
+
- README.md
|
145
|
+
- app/controllers/.keep
|
146
|
+
- app/controllers/main_controller.rb
|
147
|
+
- bin/rails
|
148
|
+
- config/routes.rb
|
149
|
+
- lib/rails-dribbble-oauth.rb
|
150
|
+
- lib/rails-dribbble-oauth/engine.rb
|
151
|
+
- lib/rails-dribbble-oauth/version.rb
|
152
|
+
- rails-dribbble-oauth.gemspec
|
153
|
+
- screenshots/callback_screenshot.png
|
154
|
+
- screenshots/oauth_request.png
|
155
|
+
- spec/controllers/main_controller_spec.rb
|
156
|
+
- spec/rails_helper.rb
|
157
|
+
- spec/routing/routing_spec.rb
|
158
|
+
- spec/spec_helper.rb
|
110
159
|
homepage: https://github.com/mindplace/rails-dribbble-oauth
|
111
160
|
licenses:
|
112
161
|
- MIT
|
@@ -119,15 +168,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
168
|
requirements:
|
120
169
|
- - ">="
|
121
170
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
171
|
+
version: '0'
|
123
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
173
|
requirements:
|
125
174
|
- - ">="
|
126
175
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
176
|
+
version: '0'
|
128
177
|
requirements: []
|
129
178
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
179
|
+
rubygems_version: 2.6.7
|
131
180
|
signing_key:
|
132
181
|
specification_version: 4
|
133
182
|
summary: A Rails engine gem for authenticating users through Dribbble, with no dependencies.
|