reflex 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +24 -0
- data/LICENSE +20 -0
- data/README.rdoc +193 -0
- data/Rakefile +146 -0
- data/VERSION +1 -0
- data/cucumber.yml +7 -0
- data/features/connect_to_provider.feature +18 -0
- data/features/social_authentication.feature +50 -0
- data/features/step_definitions/reflex_steps.rb +93 -0
- data/features/step_definitions/web_steps.rb +192 -0
- data/features/support/env.rb +57 -0
- data/features/support/mocha.rb +16 -0
- data/features/support/mock_controller/oauth_authorize.html.erb +15 -0
- data/features/support/mocks.rb +21 -0
- data/features/support/paths.rb +39 -0
- data/features/support/rails_root/.gitignore +8 -0
- data/features/support/rails_root/Rakefile +10 -0
- data/features/support/rails_root/app/controllers/application_controller.rb +20 -0
- data/features/support/rails_root/app/controllers/user_sessions_controller.rb +24 -0
- data/features/support/rails_root/app/controllers/users_controller.rb +46 -0
- data/features/support/rails_root/app/helpers/application_helper.rb +3 -0
- data/features/support/rails_root/app/helpers/user_sessions_helper.rb +2 -0
- data/features/support/rails_root/app/helpers/users_helper.rb +2 -0
- data/features/support/rails_root/app/models/user.rb +7 -0
- data/features/support/rails_root/app/models/user_session.rb +2 -0
- data/features/support/rails_root/app/views/layouts/application.html.erb +23 -0
- data/features/support/rails_root/app/views/user_sessions/new.html.erb +23 -0
- data/features/support/rails_root/app/views/users/_form.html.erb +31 -0
- data/features/support/rails_root/app/views/users/_user.html.erb +1 -0
- data/features/support/rails_root/app/views/users/edit.html.erb +2 -0
- data/features/support/rails_root/app/views/users/index.html.erb +8 -0
- data/features/support/rails_root/app/views/users/new.html.erb +2 -0
- data/features/support/rails_root/app/views/users/show.html.erb +20 -0
- data/features/support/rails_root/config/boot.rb +110 -0
- data/features/support/rails_root/config/database.yml +9 -0
- data/features/support/rails_root/config/environment.rb +22 -0
- data/features/support/rails_root/config/environments/development.rb +0 -0
- data/features/support/rails_root/config/environments/test.rb +0 -0
- data/features/support/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/features/support/rails_root/config/initializers/inflections.rb +10 -0
- data/features/support/rails_root/config/initializers/mime_types.rb +5 -0
- data/features/support/rails_root/config/initializers/new_rails_defaults.rb +21 -0
- data/features/support/rails_root/config/initializers/session_store.rb +15 -0
- data/features/support/rails_root/config/routes.rb +9 -0
- data/features/support/rails_root/db/migrate/001_create_users.rb +16 -0
- data/features/support/rails_root/db/migrate/002_create_reflex_connections.rb +17 -0
- data/features/support/rails_root/db/schema.rb +35 -0
- data/features/support/rails_root/vendor/plugins/reflex/rails/init.rb +1 -0
- data/features/traditional_registration_and_authentication.feature +39 -0
- data/init.rb +5 -0
- data/lib/reflex/authlogic/account.rb +55 -0
- data/lib/reflex/authlogic/acts_as_authentic.rb +19 -0
- data/lib/reflex/authlogic/authentication_process.rb +40 -0
- data/lib/reflex/authlogic/callback_filter.rb +26 -0
- data/lib/reflex/authlogic/connectable.rb +87 -0
- data/lib/reflex/authlogic/connection.rb +18 -0
- data/lib/reflex/authlogic/session.rb +84 -0
- data/lib/reflex/base.rb +37 -0
- data/lib/reflex/configuration.rb +38 -0
- data/lib/reflex/oauth_server.rb +47 -0
- data/lib/reflex/system.rb +25 -0
- data/lib/reflex.rb +14 -0
- data/rails/init.rb +22 -0
- data/rails_generators/reflex_connection_migration/reflex_connection_migration_generator.rb +12 -0
- data/rails_generators/reflex_connection_migration/templates/create_reflex_connections.rb +17 -0
- data/reflex.gemspec +164 -0
- data/spec/fakeweb/OAuthServer.getProviders +5 -0
- data/spec/fakeweb/OAuthServer.sessionGetProfile +5 -0
- data/spec/fakeweb/OAuthServer.tokenAccess +4 -0
- data/spec/fakeweb/OAuthServer.tokenRequest +5 -0
- data/spec/fakeweb/OAuthServer.tokenSetUserId +5 -0
- data/spec/fakeweb/OAuthServer.userGetProfile +5 -0
- data/spec/fakeweb/OAuthServer.userGetProviders +4 -0
- data/spec/fakeweb/OAuthServer.userRemoveProvider +5 -0
- data/spec/fakeweb/System.listMethods +5 -0
- data/spec/fakeweb/System.methodDescription +5 -0
- data/spec/fakeweb/System.methodSignature +5 -0
- data/spec/reflex/authlogic/connection_spec.rb +22 -0
- data/spec/reflex/base_spec.rb +29 -0
- data/spec/reflex/configuration_spec.rb +71 -0
- data/spec/reflex/oauth_server_spec.rb +219 -0
- data/spec/reflex/system_spec.rb +83 -0
- data/spec/reflex_spec.rb +5 -0
- data/spec/schema.rb +15 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +66 -0
- metadata +294 -0
data/.document
ADDED
data/.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
## MAC OS
|
|
2
|
+
.DS_Store
|
|
3
|
+
|
|
4
|
+
## TEXTMATE
|
|
5
|
+
*.tmproj
|
|
6
|
+
tmtags
|
|
7
|
+
|
|
8
|
+
## EMACS
|
|
9
|
+
*~
|
|
10
|
+
\#*
|
|
11
|
+
.\#*
|
|
12
|
+
|
|
13
|
+
## VIM
|
|
14
|
+
*.swp
|
|
15
|
+
|
|
16
|
+
## PROJECT::GENERAL
|
|
17
|
+
coverage
|
|
18
|
+
rdoc
|
|
19
|
+
pkg
|
|
20
|
+
rerun.txt
|
|
21
|
+
test.sqlite3
|
|
22
|
+
|
|
23
|
+
## PROJECT::SPECIFIC
|
|
24
|
+
reflex.yml
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 Tom-Eric Gerritsen (i76)
|
|
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.rdoc
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
= reflex
|
|
2
|
+
|
|
3
|
+
Reflex is a gem that allows you to connect your application to the React Social API.
|
|
4
|
+
|
|
5
|
+
== Install / Usage
|
|
6
|
+
|
|
7
|
+
=== 1. Install Authlogic and setup your application
|
|
8
|
+
|
|
9
|
+
Install authlogic (http://github.com/binarylogic/authlogic) in your rails application, and
|
|
10
|
+
set it up according to the authlogic docs (http://rdoc.info/projects/binarylogic/authlogic).
|
|
11
|
+
|
|
12
|
+
Take a look at the authlogic example app (http://github.com/binarylogic/authlogic_example), or
|
|
13
|
+
use it as a basis, if you get stuck.
|
|
14
|
+
|
|
15
|
+
=== 2. Install Reflex
|
|
16
|
+
|
|
17
|
+
*WARNING!* Because the reflex gem is not yet available, the notes below are incorrect. For now,
|
|
18
|
+
simply install reflex as a rails plugin and _don't_ add it in your environment.rb or Gemfile:
|
|
19
|
+
|
|
20
|
+
$ script/plugin install git@github.com:i76/reflex.git
|
|
21
|
+
|
|
22
|
+
Add the gem dependencies in your config:
|
|
23
|
+
|
|
24
|
+
==== Rails 2.3
|
|
25
|
+
|
|
26
|
+
Add the dependencies to your environment:
|
|
27
|
+
|
|
28
|
+
# config/environment.rb
|
|
29
|
+
config.gem "reflex"
|
|
30
|
+
|
|
31
|
+
And install them:
|
|
32
|
+
|
|
33
|
+
$ rake gems:install
|
|
34
|
+
|
|
35
|
+
==== Rails 3.0 (untested)
|
|
36
|
+
|
|
37
|
+
Add the dependencies to your Gemfile
|
|
38
|
+
|
|
39
|
+
# Gemfile
|
|
40
|
+
gem "reflex"
|
|
41
|
+
|
|
42
|
+
And install them:
|
|
43
|
+
|
|
44
|
+
$ bundle install
|
|
45
|
+
$ bundle lock
|
|
46
|
+
|
|
47
|
+
=== 3. Generate the reflex_connections migration
|
|
48
|
+
|
|
49
|
+
Now that we have the reflex gem installed, we need to generate a migration that connects our users to
|
|
50
|
+
a reflex provider:
|
|
51
|
+
|
|
52
|
+
==== Rails 2.3
|
|
53
|
+
|
|
54
|
+
$ script/generate reflex_connections_migration
|
|
55
|
+
|
|
56
|
+
==== Rails 3.0 (untested)
|
|
57
|
+
|
|
58
|
+
$ rails generate reflex_connections_migration
|
|
59
|
+
|
|
60
|
+
=== 4. Configure the reflex gem
|
|
61
|
+
|
|
62
|
+
Create a reflex configuration file:
|
|
63
|
+
|
|
64
|
+
# config/reflex.yml
|
|
65
|
+
development: &DEFAULTS
|
|
66
|
+
key: development_key
|
|
67
|
+
secret: development_secret
|
|
68
|
+
endpoint: http://social.react.com/XmlRpc_v2/
|
|
69
|
+
|
|
70
|
+
production:
|
|
71
|
+
<< DEFAULTS
|
|
72
|
+
key: production_key
|
|
73
|
+
secret: production_secret
|
|
74
|
+
|
|
75
|
+
=== 5. Make sure you save your objects properly
|
|
76
|
+
|
|
77
|
+
Save your session objects with a block. Why? Because we need to redirect the user to their login provider
|
|
78
|
+
so that they can authenticate. When we do this, we don't want to execute that block of code, because if
|
|
79
|
+
we do, we will get a DoubleRender error. Using a block allows us to skip that entire block and send the
|
|
80
|
+
user along their way if they choose to authenticate via React's OAuth Server.
|
|
81
|
+
|
|
82
|
+
You probably want to do this in your controllers. It should look something like this:
|
|
83
|
+
|
|
84
|
+
# app/controllers/user_session_controller.rb
|
|
85
|
+
def create
|
|
86
|
+
@user_session.save do |result|
|
|
87
|
+
if result
|
|
88
|
+
flash[:notice] = "Login successful!"
|
|
89
|
+
redirect_back_or_default account_url
|
|
90
|
+
else
|
|
91
|
+
render :action => :new
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
When creating new users, react_profile is set if available. In order to make use of this,
|
|
97
|
+
alter your user class like this:
|
|
98
|
+
|
|
99
|
+
# app/models/user.rb
|
|
100
|
+
class User < ActiveRecord::Base
|
|
101
|
+
acts_as_authentic
|
|
102
|
+
|
|
103
|
+
def react_profile=(profile)
|
|
104
|
+
self.name = profile['real_name'] || profile['user_name']
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
=== 6. Add providers to your login form
|
|
109
|
+
|
|
110
|
+
Add providers to your login form:
|
|
111
|
+
|
|
112
|
+
# app/views/new.html.erb
|
|
113
|
+
<h1>Log in</h1>
|
|
114
|
+
<% form_for(@user_session) do |f| %>
|
|
115
|
+
<%= f.error_messages %>
|
|
116
|
+
<h2>Log in with your account</h2>
|
|
117
|
+
<p>
|
|
118
|
+
<%= f.label :login %>
|
|
119
|
+
<br>
|
|
120
|
+
<%= f.text_field :login %>
|
|
121
|
+
</p>
|
|
122
|
+
<p>
|
|
123
|
+
<%= f.label :password %>
|
|
124
|
+
<br>
|
|
125
|
+
<%= f.password_field :password %>
|
|
126
|
+
</p>
|
|
127
|
+
<p><%= f.submit "Login" %></p>
|
|
128
|
+
|
|
129
|
+
<h2>Or log in via:</h2>
|
|
130
|
+
<% Reflex::OAuthServer.get_providers.each do |provider| %>
|
|
131
|
+
<%= f.submit provider, :name => "react_provider" %>
|
|
132
|
+
<br>
|
|
133
|
+
<% end %>
|
|
134
|
+
<% end %>
|
|
135
|
+
|
|
136
|
+
== Connecting existing users to react
|
|
137
|
+
|
|
138
|
+
Ofcourse connecting an existing user to a social network should be as easy and straightforward as
|
|
139
|
+
authenticating a new user. And luckilly it is!
|
|
140
|
+
|
|
141
|
+
Modify your user update method to accept a block:
|
|
142
|
+
|
|
143
|
+
# app/controllers/users_controller.rb
|
|
144
|
+
def update
|
|
145
|
+
@user = User.find(params[:id])
|
|
146
|
+
@user.attributes = params[:attributes]
|
|
147
|
+
|
|
148
|
+
@user.save do |result|
|
|
149
|
+
if result
|
|
150
|
+
flash[:notice] = "User updated successfully!"
|
|
151
|
+
redirect_to(@user)
|
|
152
|
+
else
|
|
153
|
+
render :action => :edit
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
And add the react providers in the view:
|
|
159
|
+
|
|
160
|
+
# app/views/users/edit.html.erb
|
|
161
|
+
<% form_for(@user) do |f| %>
|
|
162
|
+
<%= f.error_messages %>
|
|
163
|
+
<p>
|
|
164
|
+
Connect to a provider:
|
|
165
|
+
<br>
|
|
166
|
+
<% Reflex::OAuthServer.get_providers.each do |provider| %>
|
|
167
|
+
<%= f.submit provider, :name => "react_provider" %>
|
|
168
|
+
<% end %>
|
|
169
|
+
</p>
|
|
170
|
+
|
|
171
|
+
<p><%= f.submit "Save" %></p>
|
|
172
|
+
<% end %>
|
|
173
|
+
|
|
174
|
+
== Roadmap
|
|
175
|
+
|
|
176
|
+
The reflex gem is far from finished. Here are some of the upcoming features:
|
|
177
|
+
|
|
178
|
+
1. Easily access the React API — If a user connected to, for example twitter,
|
|
179
|
+
then it should be a matter of calling:
|
|
180
|
+
`@user.twitter.update_status("I've connected my Twitter profile")`
|
|
181
|
+
|
|
182
|
+
== Note on Patches/Pull Requests
|
|
183
|
+
|
|
184
|
+
* Fork the project.
|
|
185
|
+
* Make your feature addition or bug fix.
|
|
186
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
|
187
|
+
* Commit, do not mess with rakefile, version, or history.
|
|
188
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
|
189
|
+
* Send me a pull request. Bonus points for topic branches.
|
|
190
|
+
|
|
191
|
+
== Copyright
|
|
192
|
+
|
|
193
|
+
Copyright (c) 2010 Tom-Eric Gerritsen. See LICENSE for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'jeweler'
|
|
6
|
+
Jeweler::Tasks.new do |gem|
|
|
7
|
+
gem.name = "reflex"
|
|
8
|
+
gem.summary = %Q{Reflex connects your app to the React Social API}
|
|
9
|
+
gem.description = %Q{Reflex is a gem that allows you to connect your application to the React Social API}
|
|
10
|
+
gem.email = "tomeric@i76.nl"
|
|
11
|
+
gem.homepage = "http://github.com/i76/reflex"
|
|
12
|
+
gem.authors = ["Tom-Eric Gerritsen"]
|
|
13
|
+
gem.add_dependency "authlogic", ">= 2.1.3"
|
|
14
|
+
gem.add_dependency "uuidtools", ">= 2.1.1"
|
|
15
|
+
gem.add_development_dependency "cucumber", ">= 0.6.2"
|
|
16
|
+
gem.add_development_dependency "cucumber-rails", ">= 0.2.4"
|
|
17
|
+
gem.add_development_dependency "capybara", ">= 0.3.0"
|
|
18
|
+
gem.add_development_dependency "database_cleaner", ">= 0.4.3"
|
|
19
|
+
gem.add_development_dependency "mocha", ">= 0.9.8"
|
|
20
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
|
21
|
+
gem.add_development_dependency "fakeweb", ">= 1.2.8"
|
|
22
|
+
gem.add_development_dependency "mime-types", ">= 1.16"
|
|
23
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
|
24
|
+
end
|
|
25
|
+
Jeweler::GemcutterTasks.new
|
|
26
|
+
rescue LoadError
|
|
27
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
require 'spec/rake/spectask'
|
|
31
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
|
32
|
+
spec.libs << 'lib' << 'spec'
|
|
33
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
|
37
|
+
spec.libs << 'lib' << 'spec'
|
|
38
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
39
|
+
spec.rcov = true
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
task :spec => :check_dependencies
|
|
43
|
+
|
|
44
|
+
task :default => :spec
|
|
45
|
+
|
|
46
|
+
require 'rake/rdoctask'
|
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
49
|
+
|
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
51
|
+
rdoc.title = "reflex #{version}"
|
|
52
|
+
rdoc.rdoc_files.include('README*')
|
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
begin
|
|
57
|
+
require 'cucumber/rake/task'
|
|
58
|
+
load 'features/support/rails_root/Rakefile'
|
|
59
|
+
|
|
60
|
+
namespace :cucumber do
|
|
61
|
+
Cucumber::Rake::Task.new({:ok => ['db:reset']}, 'Run features that should pass') do |t|
|
|
62
|
+
t.fork = true # You may get faster startup if you set this to false
|
|
63
|
+
t.profile = 'default'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
Cucumber::Rake::Task.new({:wip => ['db:reset']}, 'Run features that are being worked on') do |t|
|
|
67
|
+
t.fork = true # You may get faster startup if you set this to false
|
|
68
|
+
t.profile = 'wip'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
desc 'Run all features'
|
|
72
|
+
task :all => [:ok, :wip]
|
|
73
|
+
end
|
|
74
|
+
desc 'Alias for cucumber:ok'
|
|
75
|
+
task :cucumber => 'cucumber:ok'
|
|
76
|
+
|
|
77
|
+
task :default => :cucumber
|
|
78
|
+
|
|
79
|
+
task :features => :cucumber do
|
|
80
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
rescue LoadError
|
|
84
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
|
85
|
+
task :cucumber do
|
|
86
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
namespace :reflex do
|
|
91
|
+
desc "Configure reflex"
|
|
92
|
+
task :config do
|
|
93
|
+
require 'yaml'
|
|
94
|
+
require 'lib/reflex'
|
|
95
|
+
|
|
96
|
+
config_file = File.join(File.dirname(__FILE__), 'spec', 'reflex.yml')
|
|
97
|
+
|
|
98
|
+
if File.exists?(config_file)
|
|
99
|
+
settings = YAML.load(File.open(config_file))
|
|
100
|
+
configuration = settings.inject({}) do |options, (key, value)|
|
|
101
|
+
options[(key.to_sym rescue key) || key] = value
|
|
102
|
+
options
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
Reflex.configure(configuration)
|
|
106
|
+
else
|
|
107
|
+
puts "** [Reflex] #{config_file} does not exist, skipping Reflex configuration"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
desc "List methods that have not yet been added to the library, but are available"
|
|
112
|
+
task :missing_methods do
|
|
113
|
+
Rake::Task['reflex:config'].invoke
|
|
114
|
+
|
|
115
|
+
def class_exists? kls
|
|
116
|
+
begin
|
|
117
|
+
kls = constantize(kls)
|
|
118
|
+
kls.kind_of? Class
|
|
119
|
+
rescue Exception
|
|
120
|
+
false
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def constantize(kls)
|
|
125
|
+
Object.module_eval("::#{kls}", __FILE__, __LINE__)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
all_methods = Reflex::System.list_methods
|
|
129
|
+
all_methods.each do |method|
|
|
130
|
+
remote_class, camel_cased_method = method.split('.')
|
|
131
|
+
local_class = "Reflex::#{remote_class}"
|
|
132
|
+
local_method = camel_cased_method.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase.to_sym
|
|
133
|
+
|
|
134
|
+
class_exists = class_exists?(local_class)
|
|
135
|
+
method_exists = class_exists && constantize(local_class).respond_to?(local_method)
|
|
136
|
+
|
|
137
|
+
unless class_exists && method_exists
|
|
138
|
+
method_description = Reflex::System.method_description(method)
|
|
139
|
+
parameters = method_description['parameters'].map { |name, doc| "(#{doc['type']}) #{name} : #{doc['description']}" }.join("\n ")
|
|
140
|
+
description = method_description['method']['description']
|
|
141
|
+
|
|
142
|
+
puts "\n == #{method} ==\n Local: #{local_class}.#{local_method}\n Parameters: #{parameters}\nDescription: #{description}\n"
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.2
|
data/cucumber.yml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%
|
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
|
4
|
+
std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
|
|
5
|
+
%>
|
|
6
|
+
default: <%= std_opts %>
|
|
7
|
+
wip: --tags @wip:3 --wip features
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Feature: Connect to provider
|
|
2
|
+
In order to use the new social login features
|
|
3
|
+
As an existing user
|
|
4
|
+
I want to connect my profile to a social provider
|
|
5
|
+
|
|
6
|
+
Scenario: Connect to a provider
|
|
7
|
+
Given a registered user exists with login: "marshall", password: "awesome"
|
|
8
|
+
And I am logged in as "marshall" with password "awesome"
|
|
9
|
+
And I am on my profile
|
|
10
|
+
And I follow "Edit my profile"
|
|
11
|
+
|
|
12
|
+
Given a token access is expected for an unregistered user
|
|
13
|
+
And a user id is set for the available token
|
|
14
|
+
When I press "Twitter"
|
|
15
|
+
# And I press "Allow"
|
|
16
|
+
|
|
17
|
+
When I go to my profile
|
|
18
|
+
Then I should see "Twitter"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Feature: Social authentication
|
|
2
|
+
In order to allow visitors to get access to certain features
|
|
3
|
+
As a visitor who is connected to one of our social providers
|
|
4
|
+
I want to login via one of these social providers
|
|
5
|
+
|
|
6
|
+
Scenario: Logging in for the first time
|
|
7
|
+
Given I am on the homepage
|
|
8
|
+
And I follow "Login"
|
|
9
|
+
|
|
10
|
+
Given a token request is expected
|
|
11
|
+
When I press "Twitter"
|
|
12
|
+
|
|
13
|
+
Given a token access is expected for an unregistered user
|
|
14
|
+
And a session profile fetched is expected
|
|
15
|
+
And a user id is set for the available token
|
|
16
|
+
When I press "Allow"
|
|
17
|
+
|
|
18
|
+
Then I should be logged in
|
|
19
|
+
And I should see "Marshall Eriksen"
|
|
20
|
+
|
|
21
|
+
Scenario: Logging in for the second time
|
|
22
|
+
Given a "Twitter" user exists
|
|
23
|
+
And I am on the homepage
|
|
24
|
+
Then I should see "Marshall Eriksen"
|
|
25
|
+
|
|
26
|
+
When I follow "Login"
|
|
27
|
+
|
|
28
|
+
Given a token request is expected
|
|
29
|
+
When I press "Twitter"
|
|
30
|
+
|
|
31
|
+
Given a token access is expected for a registered user
|
|
32
|
+
When I press "Allow"
|
|
33
|
+
And I should be logged in
|
|
34
|
+
And 1 user should exist
|
|
35
|
+
|
|
36
|
+
When I follow "My Profile"
|
|
37
|
+
Then I should see "Marshall Eriksen"
|
|
38
|
+
|
|
39
|
+
Scenario: Updating my profile
|
|
40
|
+
Given I login as the "Twitter" user "Marshall Eriksen"
|
|
41
|
+
And I am on the homepage
|
|
42
|
+
|
|
43
|
+
When I follow "My Profile"
|
|
44
|
+
And I follow "Edit my profile"
|
|
45
|
+
And I fill in "Name" with "Big Fudge"
|
|
46
|
+
And I press "Save"
|
|
47
|
+
Then I should see "Succesfully updated user"
|
|
48
|
+
|
|
49
|
+
When I follow "My Profile"
|
|
50
|
+
Then I should see "Big Fudge"
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Given /^a "([^\"]*)" user exists$/ do |provider|
|
|
2
|
+
Given "a \"#{provider}\" user exists with name: \"Marshall Eriksen\""
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Given /^a "([^\"]*)" user exists with name: "([^\"]*)"$/ do |provider, name|
|
|
6
|
+
record = User.new(:name => name)
|
|
7
|
+
record.reflex_connections.build(:provider => 'Twitter')
|
|
8
|
+
record.save!
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Given /^I login as the "([^\"]*)" user "([^\"]*)"$/ do |provider, name|
|
|
12
|
+
Given "a \"#{provider}\" user exists with name: \"#{name}\""
|
|
13
|
+
And "I am on the login page"
|
|
14
|
+
|
|
15
|
+
Given "a token request is expected"
|
|
16
|
+
When "I press \"Twitter\""
|
|
17
|
+
|
|
18
|
+
Given "a token access is expected for a registered user"
|
|
19
|
+
When "I press \"Allow\""
|
|
20
|
+
|
|
21
|
+
Then "I should be logged in"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Given /^([0-9]+) users? should exist$/ do |count|
|
|
25
|
+
User.count.should eql(count.to_i)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Given /^a token request is expected$/ do
|
|
29
|
+
@provider ||= 'Twitter'
|
|
30
|
+
|
|
31
|
+
Reflex::OAuthServer.expects(:token_request).with(@provider).returns({
|
|
32
|
+
'redirectUrl' => 'https://twitter.com/fake_controller/oauth/authorize',
|
|
33
|
+
'reactOAuthSession' => 'FAKE_OAUTH_TOKEN'
|
|
34
|
+
})
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
Given /^a token access is expected for an unregistered user$/ do
|
|
38
|
+
@provider ||= 'Twitter'
|
|
39
|
+
|
|
40
|
+
Reflex::OAuthServer.expects(:token_access).returns({
|
|
41
|
+
'connectedWithProvider' => @provider,
|
|
42
|
+
'reactOAuthSession' => 'FAKE_REACT_OAUTH_SESSION'
|
|
43
|
+
})
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
Given /^a token access is expected for a registered user$/ do
|
|
47
|
+
@provider ||= 'Twitter'
|
|
48
|
+
application_user_id = User.last.reflex_connections.first.uuid
|
|
49
|
+
|
|
50
|
+
Reflex::OAuthServer.expects(:token_access).returns({
|
|
51
|
+
'connectedWithProvider' => @provider,
|
|
52
|
+
'reactOAuthSession' => 'FAKE_REACT_OAUTH_SESSION',
|
|
53
|
+
'applicationUserId' => application_user_id
|
|
54
|
+
})
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Given /^a session profile fetched is expected$/ do
|
|
58
|
+
Reflex::OAuthServer.expects(:session_get_profile).with('FAKE_OAUTH_TOKEN').returns({
|
|
59
|
+
'real_name' => 'Marshall Eriksen',
|
|
60
|
+
'user_name' => 'marshall',
|
|
61
|
+
'profile_picture' => 'http://awesome.com/marshall.jpg'
|
|
62
|
+
})
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Given /^a user id is set for the available token$/ do
|
|
66
|
+
@provider ||= 'Twitter'
|
|
67
|
+
|
|
68
|
+
Reflex::OAuthServer.expects(:token_set_user_id).returns({
|
|
69
|
+
'applicationUserId' => 1,
|
|
70
|
+
'connectedWithProvider' => @provider,
|
|
71
|
+
})
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
Given /^a registered user exists with login: "([^\"]*)", password: "([^\"]*)"$/ do |login, password|
|
|
75
|
+
User.create!(:login => login, :name => login, :password => password, :password_confirmation => password)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
Given /^I am logged in as "([^\"]*)" with password "([^\"]*)"$/ do |login, password|
|
|
79
|
+
When "I am on the login page"
|
|
80
|
+
And "I fill in \"Login\" with \"#{login}\""
|
|
81
|
+
And "I fill in \"Password\" with \"#{password}\""
|
|
82
|
+
And "I press \"Login\""
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
Then /^I should be logged out$/ do
|
|
86
|
+
Then "I should not see \"My Profile\""
|
|
87
|
+
And "I should see \"Login\""
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
Then /^I should be logged in$/ do
|
|
91
|
+
Then "I should see \"My Profile\""
|
|
92
|
+
And "I should see \"Logout\""
|
|
93
|
+
end
|