|
6 | 6 | context 'GET User Permission' do
|
7 | 7 | context 'User accepts' do
|
8 | 8 | it 'redirects to new ' do
|
9 |
| - VCR.use_cassette 'controllers/api-permissions' do |
| 9 | + VCR.use_cassette 'controllers/api-permissions-denied' do |
| 10 | +=begin |
10 | 11 | data = {
|
11 | 12 | name: 'google',
|
12 | 13 | scope: 'userinfo.profile,userinfo.email,drive,https://spreadsheets.google.com/feeds',
|
13 | 14 | prompt: 'consent',
|
14 | 15 | access_type: 'offline',
|
15 | 16 | redirect_uri: 'http://localhost:8080/auth/google/callback'
|
16 | 17 | }
|
17 |
| - RestClient.post 'https://accounts.google.com/o/oauth2/auth', data |
| 18 | + RestClient.get 'https://accounts.google.com/o/oauth2/auth', |
| 19 | + name: 'google', |
| 20 | + scope: 'userinfo.profile,userinfo.email,drive,https://spreadsheets.google.com/feeds', |
| 21 | + prompt: 'consent', |
| 22 | + access_type: 'offline', |
| 23 | + redirect_uri: 'http://localhost:8080/auth/google/callback' |
| 24 | +=end |
18 | 25 | end
|
19 | 26 |
|
20 | 27 | end
|
|
36 | 43 | end
|
37 | 44 |
|
38 | 45 | context 'GET New' do
|
| 46 | + let(:sheet) { FactoryGirl.create(:spreadsheet)} |
39 | 47 | it 'creates new spreadsheet when no access_token given' do
|
40 | 48 | VCR.use_cassette 'controllers/api-new_tokens' do
|
41 | 49 | request.env['omniauth.auth'] = {
|
|
52 | 60 | end
|
53 | 61 | end
|
54 | 62 |
|
55 |
| - let(:sheet) { FactoryGirl.create(:spreadsheet)} |
56 | 63 | it 'does not creates new spreadsheet when access_token is given' do
|
57 | 64 | VCR.use_cassette 'controllers/api-response' do
|
58 | 65 | get(:new, access_token: sheet.access_token)
|
59 | 66 | expect(response).to render_template(:new)
|
60 | 67 | end
|
61 | 68 | end
|
| 69 | + |
| 70 | + it 'does not creates new spreadsheet if access_token already present' do |
| 71 | + sheet |
| 72 | + |
| 73 | + VCR.use_cassette 'controllers/api-new_tokens' do |
| 74 | + request.env['omniauth.auth'] = { |
| 75 | + 'credentials' => { |
| 76 | + 'token' => sheet[:access_token], |
| 77 | + 'refresh_token' => sheet[:refresh_token], |
| 78 | + 'expires_at' => Time.now, |
| 79 | + 'expires' => true |
| 80 | + } |
| 81 | + } |
| 82 | + get :new |
| 83 | + expect(assigns(:msg)).not_to be(nil) |
| 84 | + end |
| 85 | + end |
62 | 86 | end
|
63 | 87 |
|
64 | 88 | context 'Get Edit' do
|
|
0 commit comments