|
1 | 1 | require 'spec_helper'
|
2 | 2 |
|
3 |
| -RSpec.describe UsersController, type: :controller, skip: true do |
| 3 | +RSpec.describe UsersController, type: :controller do |
4 | 4 | let(:user) do
|
5 | 5 | user = Fabricate.build(:user)
|
6 | 6 | user.badges << Fabricate.build(:badge, badge_class_name: 'Octopussy')
|
7 | 7 | user.save!
|
8 | 8 | user
|
9 | 9 | end
|
10 | 10 |
|
11 |
| - let(:github_response) do { |
12 |
| - 'provider' => 'github', |
13 |
| - 'uid' => 1_310_330, |
14 |
| - 'info' => { 'nickname' => 'throwaway1', |
15 |
| - 'email' => 'md@asdf.com', |
16 |
| - 'name' => nil, |
17 |
| - 'urls' => { 'GitHub' => 'https://github.com/throwaway1', 'Blog' => nil } }, |
18 |
| - 'credentials' => { 'token' => '59cdff603a4e70d47f0a28b5ccaa3935aaa790cf', 'expires' => false }, |
19 |
| - 'extra' => { 'raw_info' => { 'owned_private_repos' => 0, |
20 |
| - 'type' => 'User', |
21 |
| - 'avatar_url' => 'https://secure.gravatar.com/avatar/b08ed2199f8a88360c9679a57c4f9305?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png', |
22 |
| - 'created_at' => '2012-01-06T20:49:02Z', |
23 |
| - 'login' => 'throwaway1', |
24 |
| - 'disk_usage' => 0, |
25 |
| - 'plan' => { 'space' => 307_200, |
26 |
| - 'private_repos' => 0, |
27 |
| - 'name' => 'free', |
28 |
| - 'collaborators' => 0 }, |
29 |
| - 'public_repos' => 0, |
30 |
| - 'following' => 0, |
31 |
| - 'public_gists' => 0, |
32 |
| - 'followers' => 0, |
33 |
| - 'gravatar_id' => 'b08ed2199f8a88360c9679a57c4f9305', |
34 |
| - 'total_private_repos' => 0, |
35 |
| - 'collaborators' => 0, |
36 |
| - 'html_url' => 'https://github.com/throwaway1', |
37 |
| - 'url' => 'https://api.github.com/users/throwaway1', |
38 |
| - 'id' => 1_310_330, |
39 |
| - 'private_gists' => 0 } } }.with_indifferent_access end |
| 11 | + let(:github_response) { JSON.parse(File.read('./spec/fixtures/oauth/github_response.json')).with_indifferent_access } |
40 | 12 |
|
41 | 13 | it 'should get user page by ignoring the case' do
|
42 | 14 | get :show, username: user.username.downcase
|
|
108 | 80 | it 'applies oauth information to user on creation' do
|
109 | 81 | session['oauth.data'] = github_response
|
110 | 82 | post :create, user: { location: 'SF' }
|
111 |
| - # assigns[:user].thumbnail_url == 'https://secure.gravatar.com/avatar/b08ed2199f8a88360c9679a57c4f9305' |
112 | 83 | assigns[:user].github == 'throwaway1'
|
113 | 84 | assigns[:user].github_token == '59cdff603a4e70d47f0a28b5ccaa3935aaa790cf'
|
114 | 85 | end
|
|
135 | 106 | end
|
136 | 107 |
|
137 | 108 | describe 'linkedin' do
|
138 |
| - let(:linkedin_response) do { |
139 |
| - 'provider' => 'linkedin', |
140 |
| - 'uid' => 'DlC5AmUPnM', |
141 |
| - 'info' => { 'first_name' => 'Matthew', |
142 |
| - 'last_name' => 'Deiters', |
143 |
| - 'name' => 'Matthew Deiters', |
144 |
| - 'headline' => '-', |
145 |
| - 'image' => 'http://media.linkedin.com/mpr/mprx/0_gPLYkP6hYm6ap1Vcxq5TkrTSYulmpzUc0tA3krFxTW5YiluBAvztoKPlKGAlx-sRyKF8wBv2M2QD', |
146 |
| - 'industry' => 'Computer Software', |
147 |
| - 'urls' => { 'public_profile' => 'http://www.linkedin.com/in/matthewdeiters' } }, |
148 |
| - 'credentials' => { 'token' => 'acafe540-606a-4f73-aef7-f6eba276603', 'secret' => 'df7427be-3d93-4563-baef-d1d38826686' }, |
149 |
| - 'extra' => { 'raw_info' => { 'firstName' => 'Matthew', |
150 |
| - 'headline' => '-', |
151 |
| - 'id' => 'DlC5AmUPnM', |
152 |
| - 'industry' => 'Computer Software', |
153 |
| - 'lastName' => 'Deiters', |
154 |
| - 'pictureUrl' => 'http://media.linkedin.com/mpr/mprx/0_gPLYkP6hYm6ap1Vcxq5TkrTSYulmpzUc0tA3krFxTW5YiluBAvztoKPlKGAlx-sRyKF8wBv2M2QD', |
155 |
| - 'publicProfileUrl' => 'http://www.linkedin.com/in/matthewdeiters' } } }.with_indifferent_access end |
| 109 | + let(:linkedin_response) { JSON.parse(File.read('./spec/fixtures/oauth/linkedin_response.json')).with_indifferent_access } |
156 | 110 |
|
157 | 111 | it 'setups up new user and redirects to signup page' do
|
158 | 112 | session['oauth.data'] = linkedin_response
|
|
169 | 123 | end
|
170 | 124 |
|
171 | 125 | describe 'twitter' do
|
172 |
| - let(:twitter_response) do { |
173 |
| - 'provider' => 'twitter', |
174 |
| - 'uid' => '6271932', |
175 |
| - 'info' => { 'nickname' => 'mdeiters', |
176 |
| - 'name' => 'matthew deiters', |
177 |
| - 'location' => 'San Francisco', |
178 |
| - 'image' => 'http://a1.twimg.com/profile_images/1672080012/instagram_profile_normal.jpg', |
179 |
| - 'description' => 'Dad. Amateur Foodie. Founder Extraordinaire of @coderwall', |
180 |
| - 'urls' => { 'Website' => 'http://coderwall.com/mdeiters', 'Twitter' => 'http://twitter.com/mdeiters' } }, |
181 |
| - 'credentials' => { 'token' => '6271932-8erxrXfJykBNMrvsdCEq5WqKd6FIcO97L9BzvPq7', |
182 |
| - 'secret' => '8fRS1ZARd6Wm53wvvDwHNrBmZcW0H2aSwmQjuOTHl' }, |
183 |
| - 'extra' => { |
184 |
| - 'raw_info' => { 'lang' => 'en', |
185 |
| - 'profile_background_image_url' => 'http://a2.twimg.com/profile_background_images/6771536/Fresh-Grass_1600.jpg', |
186 |
| - 'protected' => false, |
187 |
| - 'time_zone' => 'Pacific Time (US & Canada)', |
188 |
| - 'created_at' => 'Wed May 23 21:14:29 +0000 2007', |
189 |
| - 'profile_link_color' => '0084B4', |
190 |
| - 'name' => 'matthew deiters', |
191 |
| - 'listed_count' => 27, |
192 |
| - 'contributors_enabled' => false, |
193 |
| - 'followers_count' => 375, |
194 |
| - 'profile_image_url' => 'http://a1.twimg.com/profile_images/1672080012/instagram_profile_normal.jpg', |
195 |
| - 'utc_offset' => -28_800, |
196 |
| - 'profile_background_color' => '9AE4E8', |
197 |
| - 'description' => 'Dad. Amateur Foodie. Founder Extraordinaire of @coderwall', |
198 |
| - 'statuses_count' => 720, |
199 |
| - 'profile_background_tile' => false, |
200 |
| - 'following' => false, |
201 |
| - 'verified' => false, |
202 |
| - 'profile_sidebar_fill_color' => 'DDFFCC', |
203 |
| - 'status' => { 'in_reply_to_user_id' => 5_446_832, |
204 |
| - 'favorited' => false, 'place' => nil, |
205 |
| - 'created_at' => 'Sat Jan 07 01:57:54 +0000 2012', |
206 |
| - 'retweet_count' => 0, |
207 |
| - 'in_reply_to_screen_name' => 'chrislloyd', |
208 |
| - 'in_reply_to_status_id_str' => '155460652457148416', |
209 |
| - 'retweeted' => false, |
210 |
| - 'in_reply_to_user_id_str' => '5446832', |
211 |
| - 'geo' => nil, |
212 |
| - 'in_reply_to_status_id' => 155_460_652_457_148_416, |
213 |
| - 'id_str' => '155468169815932928', |
214 |
| - 'contributors' => nil, |
215 |
| - 'coordinates' => nil, |
216 |
| - 'truncated' => false, |
217 |
| - 'source' => "<a href=\"http://twitter.com/#!/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>", |
218 |
| - 'id' => 155_468_169_815_932_928, |
219 |
| - 'text' => '@minefold @chrislloyd FYI your losing seo juice with a blog sub domain' }, |
220 |
| - 'default_profile_image' => false, |
221 |
| - 'friends_count' => 301, |
222 |
| - 'location' => 'San Francisco', |
223 |
| - 'screen_name' => 'mdeiters', |
224 |
| - 'default_profile' => false, |
225 |
| - 'profile_background_image_url_https' => 'https://si0.twimg.com/profile_background_images/6771536/Fresh-Grass_1600.jpg', |
226 |
| - 'profile_sidebar_border_color' => 'BDDCAD', |
227 |
| - 'id_str' => '6271932', |
228 |
| - 'is_translator' => false, |
229 |
| - 'geo_enabled' => true, |
230 |
| - 'url' => 'http://coderwall.com/mdeiters', |
231 |
| - 'profile_image_url_https' => 'https://si0.twimg.com/profile_images/1672080012/instagram_profile_normal.jpg', |
232 |
| - 'profile_use_background_image' => true, |
233 |
| - 'favourites_count' => 178, |
234 |
| - 'id' => 6_271_932, |
235 |
| - 'show_all_inline_media' => false, |
236 |
| - 'follow_request_sent' => false, |
237 |
| - 'notifications' => false, |
238 |
| - 'profile_text_color' => '333333' } } }.with_indifferent_access end |
| 126 | + let(:twitter_response) { JSON.parse(File.read('./spec/fixtures/oauth/twitter_response.json')).with_indifferent_access } |
239 | 127 |
|
240 | 128 | it 'setups up new user and redirects to signup page' do
|
241 | 129 | session['oauth.data'] = twitter_response
|
|
0 commit comments