dailycred 0.1.35 → 0.1.36
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +24 -2
- data/dailycred.gemspec +1 -1
- data/dummy/.gitignore +15 -0
- data/dummy/Gemfile +52 -0
- data/dummy/Guardfile +31 -0
- data/dummy/README.rdoc +261 -0
- data/dummy/Rakefile +7 -0
- data/dummy/app/assets/images/rails.png +0 -0
- data/dummy/app/assets/javascripts/application.js +15 -0
- data/dummy/app/assets/javascripts/posts.js.coffee +3 -0
- data/dummy/app/assets/stylesheets/application.css +13 -0
- data/dummy/app/assets/stylesheets/posts.css.scss +3 -0
- data/dummy/app/assets/stylesheets/scaffolds.css.scss +69 -0
- data/dummy/app/controllers/application_controller.rb +15 -0
- data/dummy/app/controllers/posts_controller.rb +85 -0
- data/dummy/app/helpers/application_helper.rb +2 -0
- data/dummy/app/helpers/posts_helper.rb +2 -0
- data/dummy/app/mailers/.gitkeep +0 -0
- data/dummy/app/models/.gitkeep +0 -0
- data/dummy/app/models/post.rb +3 -0
- data/dummy/app/models/user.rb +3 -0
- data/dummy/app/views/layouts/application.html.erb +14 -0
- data/dummy/app/views/posts/_form.html.erb +21 -0
- data/dummy/app/views/posts/edit.html.erb +6 -0
- data/dummy/app/views/posts/index.html.erb +23 -0
- data/dummy/app/views/posts/new.html.erb +5 -0
- data/dummy/app/views/posts/show.html.erb +10 -0
- data/dummy/config/application.rb +62 -0
- data/dummy/config/boot.rb +6 -0
- data/dummy/config/database.yml +25 -0
- data/dummy/config/environment.rb +5 -0
- data/dummy/config/environments/development.rb +37 -0
- data/dummy/config/environments/production.rb +67 -0
- data/dummy/config/environments/test.rb +37 -0
- data/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/dummy/config/initializers/inflections.rb +15 -0
- data/dummy/config/initializers/mime_types.rb +5 -0
- data/dummy/config/initializers/omniauth.rb +9 -0
- data/dummy/config/initializers/secret_token.rb +7 -0
- data/dummy/config/initializers/session_store.rb +8 -0
- data/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/dummy/config/locales/en.yml +5 -0
- data/dummy/config/routes.rb +61 -0
- data/dummy/config.ru +4 -0
- data/dummy/db/migrate/20120925172903_create_users.rb +68 -0
- data/dummy/db/migrate/20120926012555_create_posts.rb +9 -0
- data/dummy/db/schema.rb +44 -0
- data/dummy/db/seeds.rb +7 -0
- data/dummy/lib/assets/.gitkeep +0 -0
- data/dummy/lib/tasks/.gitkeep +0 -0
- data/dummy/log/.gitkeep +0 -0
- data/dummy/public/404.html +26 -0
- data/dummy/public/422.html +26 -0
- data/dummy/public/500.html +25 -0
- data/dummy/public/favicon.ico +0 -0
- data/dummy/public/index.html +241 -0
- data/dummy/public/robots.txt +5 -0
- data/dummy/script/rails +6 -0
- data/dummy/test/fixtures/.gitkeep +0 -0
- data/dummy/test/fixtures/posts.yml +7 -0
- data/dummy/test/fixtures/users.yml +3 -0
- data/dummy/test/functional/.gitkeep +0 -0
- data/dummy/test/functional/posts_controller_test.rb +51 -0
- data/dummy/test/integration/.gitkeep +0 -0
- data/dummy/test/performance/browsing_test.rb +12 -0
- data/dummy/test/test_helper.rb +62 -0
- data/dummy/test/unit/.gitkeep +0 -0
- data/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
- data/dummy/test/unit/post_test.rb +7 -0
- data/dummy/test/unit/user_test.rb +72 -0
- data/dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/dummy/vendor/plugins/.gitkeep +0 -0
- data/lib/dailycred/acts_as_dailycred.rb +40 -3
- data/lib/dailycred/client.rb +3 -1
- data/lib/dailycred/engine.rb +2 -1
- data/lib/generators/dailycred_generator.rb +1 -1
- data/lib/generators/templates/migration_create_user.rb +6 -2
- data/lib/omniauth/strategies/dailycred.rb +2 -5
- data/spec/support/dailycred_spec.rb +1 -1
- metadata +73 -2
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,241 @@
|
|
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’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’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’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"> </div>
|
239
|
+
</div>
|
240
|
+
</body>
|
241
|
+
</html>
|
data/dummy/script/rails
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
File without changes
|
File without changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PostsControllerTest < ActionController::TestCase
|
4
|
+
setup do
|
5
|
+
@post = posts(:one)
|
6
|
+
@user = users(:basic)
|
7
|
+
@controller.expects(:current_user).returns(@user)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "should get index" do
|
11
|
+
get :index
|
12
|
+
assert_response :success
|
13
|
+
assert_not_nil assigns(:posts)
|
14
|
+
end
|
15
|
+
|
16
|
+
test "should get new" do
|
17
|
+
get :new
|
18
|
+
assert_response :success
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should create post" do
|
22
|
+
assert_difference('Post.count') do
|
23
|
+
post :create, post: { title: @post.title }
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_redirected_to post_path(assigns(:post))
|
27
|
+
end
|
28
|
+
|
29
|
+
test "should show post" do
|
30
|
+
get :show, id: @post
|
31
|
+
assert_response :success
|
32
|
+
end
|
33
|
+
|
34
|
+
test "should get edit" do
|
35
|
+
get :edit, id: @post
|
36
|
+
assert_response :success
|
37
|
+
end
|
38
|
+
|
39
|
+
test "should update post" do
|
40
|
+
put :update, id: @post, post: { title: @post.title }
|
41
|
+
assert_redirected_to post_path(assigns(:post))
|
42
|
+
end
|
43
|
+
|
44
|
+
test "should destroy post" do
|
45
|
+
assert_difference('Post.count', -1) do
|
46
|
+
delete :destroy, id: @post
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_redirected_to posts_path
|
50
|
+
end
|
51
|
+
end
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rails/performance_test_help'
|
3
|
+
|
4
|
+
class BrowsingTest < ActionDispatch::PerformanceTest
|
5
|
+
# Refer to the documentation for all available options
|
6
|
+
# self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
|
7
|
+
# :output => 'tmp/performance', :formats => [:flat] }
|
8
|
+
|
9
|
+
def test_homepage
|
10
|
+
get '/'
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spork'
|
3
|
+
#uncomment the following line to use spork with the debugger
|
4
|
+
#require 'spork/ext/ruby-debug'
|
5
|
+
|
6
|
+
Spork.prefork do
|
7
|
+
# Loading more in this block will cause your tests to run faster. However,
|
8
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
9
|
+
# need to restart spork for it take effect.
|
10
|
+
ENV["RAILS_ENV"] = "test"
|
11
|
+
require File.expand_path('../../config/environment', __FILE__)
|
12
|
+
require 'rails/test_help'
|
13
|
+
|
14
|
+
class ActiveSupport::TestCase
|
15
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
16
|
+
#
|
17
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
18
|
+
# -- they do not yet inherit this setting
|
19
|
+
fixtures :all
|
20
|
+
|
21
|
+
# Add more helper methods to be used by all tests here...
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
Spork.each_run do
|
27
|
+
# This code will be run each time you run your specs.
|
28
|
+
end
|
29
|
+
|
30
|
+
# --- Instructions ---
|
31
|
+
# Sort the contents of this file into a Spork.prefork and a Spork.each_run
|
32
|
+
# block.
|
33
|
+
#
|
34
|
+
# The Spork.prefork block is run only once when the spork server is started.
|
35
|
+
# You typically want to place most of your (slow) initializer code in here, in
|
36
|
+
# particular, require'ing any 3rd-party gems that you don't normally modify
|
37
|
+
# during development.
|
38
|
+
#
|
39
|
+
# The Spork.each_run block is run each time you run your specs. In case you
|
40
|
+
# need to load files that tend to change during development, require them here.
|
41
|
+
# With Rails, your application modules are loaded automatically, so sometimes
|
42
|
+
# this block can remain empty.
|
43
|
+
#
|
44
|
+
# Note: You can modify files loaded *from* the Spork.each_run block without
|
45
|
+
# restarting the spork server. However, this file itself will not be reloaded,
|
46
|
+
# so if you change any of the code inside the each_run block, you still need to
|
47
|
+
# restart the server. In general, if you have non-trivial code in this file,
|
48
|
+
# it's advisable to move it into a separate file so you can easily edit it
|
49
|
+
# without restarting spork. (For example, with RSpec, you could move
|
50
|
+
# non-trivial code into a file spec/support/my_helper.rb, making sure that the
|
51
|
+
# spec/support/* files are require'd from inside the each_run block.)
|
52
|
+
#
|
53
|
+
# Any code that is left outside the two blocks will be run during preforking
|
54
|
+
# *and* during each_run -- that's probably not what you want.
|
55
|
+
#
|
56
|
+
# These instructions should self-destruct in 10 seconds. If they don't, feel
|
57
|
+
# free to delete them.
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
File without changes
|
@@ -0,0 +1,72 @@
|
|
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
|
+
def json_response response
|
62
|
+
JSON.parse response.body
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def assert_tag tag
|
67
|
+
assert_true @user.tags.include?(tag), "user should have tag: #{tag} but has tags: #{@user.tags}"
|
68
|
+
end
|
69
|
+
def assert_not_tag tag
|
70
|
+
assert_false @user.tags.include?(tag), "user should not have tag: #{tag} but has tags: #{@user.tags}"
|
71
|
+
end
|
72
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -7,18 +7,55 @@ module ActsAsDailycred
|
|
7
7
|
serialize :tags, Array
|
8
8
|
serialize :referred, Array
|
9
9
|
|
10
|
-
attr_accessible :email, :username, :created, :verified, :admin, :referred_by, :referred,
|
11
|
-
:facebook, :tags, :provider, :uid, :token, :twitter, :google, :github
|
12
10
|
extend ActsAsDailycred::SingletonMethods
|
11
|
+
include ActsAsDailycred::InstanceMethods
|
13
12
|
end
|
14
13
|
module SingletonMethods
|
15
14
|
def find_or_create_with_omniauth(model)
|
16
15
|
@user = User.find_by_provider_and_uid(model[:provider], model[:uid]) || User.new
|
17
|
-
@user.
|
16
|
+
@user.update_from_dailycred model[:info]
|
18
17
|
@user
|
19
18
|
end
|
20
19
|
end
|
21
20
|
module InstanceMethods
|
21
|
+
def tag tag
|
22
|
+
dc = get_client
|
23
|
+
response = dc.tag self.uid, tag
|
24
|
+
json = JSON.parse(response.body)
|
25
|
+
if json['worked']
|
26
|
+
self.tags << tag
|
27
|
+
save!
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def untag tag
|
32
|
+
dc = get_client
|
33
|
+
response = dc.untag self.uid, tag
|
34
|
+
json = JSON.parse(response.body)
|
35
|
+
if json['worked']
|
36
|
+
self.tags.delete tag
|
37
|
+
save!
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def reset_password
|
42
|
+
get_client.reset_password self.email
|
43
|
+
end
|
44
|
+
|
45
|
+
def update_from_dailycred dc
|
46
|
+
dc.each do |k,v|
|
47
|
+
self[k] = v if self[k] != v
|
48
|
+
end
|
49
|
+
save!
|
50
|
+
end
|
51
|
+
|
52
|
+
def fire_event key, val=""
|
53
|
+
get_client.event self.uid, key, val
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_client
|
57
|
+
@dailycred ||= Dailycred::Client.new Rails.configuration.DAILYCRED_CLIENT_ID, Rails.configuration.DAILYCRED_SECRET_KEY
|
58
|
+
end
|
22
59
|
end
|
23
60
|
end
|
24
61
|
require 'active_record'
|
data/lib/dailycred/client.rb
CHANGED
@@ -61,7 +61,7 @@ module Dailycred
|
|
61
61
|
# Send a reset password email
|
62
62
|
#
|
63
63
|
# - @param [string] user the user's email or username
|
64
|
-
def
|
64
|
+
def reset_password(user)
|
65
65
|
opts = {
|
66
66
|
:user => user
|
67
67
|
}
|
@@ -85,6 +85,8 @@ module Dailycred
|
|
85
85
|
opts = {}
|
86
86
|
if @options[:client_options] && @options[:client_options][:ssl]
|
87
87
|
opts[:ssl] = @options[:client_options][:ssl]
|
88
|
+
elsif Rails.configuration.respond_to? "DAILYCRED_OPTIONS"
|
89
|
+
opts[:ssl] = Rails.configuration.DAILYCRED_OPTIONS[:client_options][:ssl]
|
88
90
|
end
|
89
91
|
opts
|
90
92
|
end
|
data/lib/dailycred/engine.rb
CHANGED
@@ -23,7 +23,6 @@ module Dailycred
|
|
23
23
|
opts[:client_options][:ssl] = {}
|
24
24
|
else
|
25
25
|
opts = {:client_options => {:ssl => {}}}
|
26
|
-
conf.DAILYCRED_OPTIONS = opts
|
27
26
|
end
|
28
27
|
|
29
28
|
if File.exists?('/etc/ssl/certs')
|
@@ -33,6 +32,8 @@ module Dailycred
|
|
33
32
|
opts[:client_options][:ssl][:ca_file] = '/opt/local/share/curl/curl-ca-bundle.crt'
|
34
33
|
end
|
35
34
|
|
35
|
+
conf.DAILYCRED_OPTIONS = opts
|
36
|
+
|
36
37
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
37
38
|
provider :dailycred, id, secret, opts
|
38
39
|
end
|
@@ -5,7 +5,7 @@ class CreateUsers < ActiveRecord::Migration
|
|
5
5
|
t.string :provider
|
6
6
|
t.string :uid
|
7
7
|
t.string :email
|
8
|
-
t.integer :created
|
8
|
+
t.integer :created
|
9
9
|
t.string :username
|
10
10
|
t.boolean :verified
|
11
11
|
t.boolean :admin
|
@@ -17,6 +17,8 @@ class CreateUsers < ActiveRecord::Migration
|
|
17
17
|
t.text :google
|
18
18
|
t.text :twitter
|
19
19
|
t.text :github
|
20
|
+
t.boolean :subscribed
|
21
|
+
t.string :display
|
20
22
|
|
21
23
|
t.timestamps
|
22
24
|
end
|
@@ -36,6 +38,8 @@ class CreateUsers < ActiveRecord::Migration
|
|
36
38
|
safe_column :users, :google, :text
|
37
39
|
safe_column :users, :twitter, :text
|
38
40
|
safe_column :users, :github, :text
|
41
|
+
safe_column :users, :display, :string
|
42
|
+
safe_column :users, :subscribed, :boolean
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
@@ -58,7 +62,7 @@ class CreateUsers < ActiveRecord::Migration
|
|
58
62
|
end
|
59
63
|
|
60
64
|
def safe_column table, name, type
|
61
|
-
add_column table.to_sym, name.to_sym, type.to_sym unless
|
65
|
+
add_column table.to_sym, name.to_sym, type.to_sym unless column_exists? table, name
|
62
66
|
end
|
63
67
|
|
64
68
|
end
|