browse-everything 0.14.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdca52f24c726e1a0a0b04200f2ec65359b3b16b
4
- data.tar.gz: 181729d5c03b8c06773cbe1f2797e471ccaac5de
3
+ metadata.gz: 730808dd49026de8e75b8344369e54ccd437b397
4
+ data.tar.gz: fd60f9a6709d2dae71fedb6b6f1d5a62a0174219
5
5
  SHA512:
6
- metadata.gz: 454cadb16e026a647559e5759042aeeaa04e724733053ea6f3215ec13bd4d35cca202249ac75b6b51f53e270a77dc9008065179f0b4e5c3913a6a64a2772af29
7
- data.tar.gz: 4b4ce4d14208a57d43ec2462c96253f1a04c6546c40496bea0ab7c6450ddbbc997624035d30c18052d81a0c7db6e145877d13e8338863316febd624bea7c3199
6
+ metadata.gz: 1d5c2642e90c7dbd4babdaff36ea7408418813e00467c2a321abae41fb963bbec09aede9dfb111d7b082f7ed5781f63a81bf3f78b3088f2303ce1fe18c828347
7
+ data.tar.gz: 976c6e152a9712df3bf074a6a84df9a1d7321fe111386ed6f7c6235f8a5bde2056606b1e66ce8a5a6337dd59b16e1bc8e03301858c5124906f4388396947c919
@@ -64,12 +64,10 @@ Rails/OutputSafety:
64
64
  Rails/TimeZone:
65
65
  Exclude:
66
66
  - 'lib/browse_everything/driver/google_drive.rb'
67
- - 'lib/browse_everything/driver/sky_drive.rb'
68
67
  - 'lib/browse_everything/retriever.rb'
69
68
  - 'spec/unit/browse_everything_helper_spec.rb'
70
69
  - 'spec/unit/file_entry_spec.rb'
71
70
  - 'spec/unit/retriever_spec.rb'
72
- - 'spec/unit/sky_drive_spec.rb'
73
71
  - 'spec/views/browse_everything/_file.html.erb_spec.rb'
74
72
 
75
73
  # Offense count: 3
@@ -96,7 +94,6 @@ Style/FileName:
96
94
  Style/GuardClause:
97
95
  Exclude:
98
96
  - 'lib/browse_everything/driver/google_drive.rb'
99
- - 'lib/browse_everything/driver/sky_drive.rb'
100
97
 
101
98
  # Offense count: 1
102
99
  Style/MultilineBlockChain:
@@ -109,22 +106,6 @@ Style/MultilineBlockLayout:
109
106
  Exclude:
110
107
  - 'spec/unit/dropbox_spec.rb'
111
108
 
112
- # Offense count: 2
113
- # Cop supports --auto-correct.
114
- # Configuration parameters: EnforcedStyle, SupportedStyles.
115
- # SupportedStyles: symmetrical, new_line, same_line
116
- Style/MultilineHashBraceLayout:
117
- Exclude:
118
- - 'spec/unit/sky_drive_spec.rb'
119
-
120
- # Offense count: 4
121
- # Cop supports --auto-correct.
122
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
123
- # SupportedStyles: aligned, indented, indented_relative_to_receiver
124
- Style/MultilineMethodCallIndentation:
125
- Exclude:
126
- - 'spec/unit/sky_drive_spec.rb'
127
-
128
109
  # Offense count: 1
129
110
  # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
130
111
  # NamePrefix: is_, has_, have_
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/browse-everything.png)](http://badge.fury.io/rb/browse-everything)
2
- [![Build Status](https://travis-ci.org/projecthydra/browse-everything.svg?branch=master)](https://travis-ci.org/projecthydra/browse-everything)
3
- [![Coverage Status](https://coveralls.io/repos/projecthydra/browse-everything/badge.svg?branch=master&service=github)](https://coveralls.io/github/projecthydra/browse-everything?branch=master)
2
+ [![Build Status](https://travis-ci.org/samvera/browse-everything.svg?branch=master)](https://travis-ci.org/samvera/browse-everything)
3
+ [![Coverage Status](https://coveralls.io/repos/samvera/browse-everything/badge.svg?branch=master&service=github)](https://coveralls.io/github/samvera/browse-everything?branch=master)
4
4
 
5
5
  # BrowseEverything
6
6
 
7
7
  This Gem allows your rails application to access user files from cloud storage.
8
8
  Currently there are drivers implemented for [Dropbox](http://www.dropbox.com),
9
- [Skydrive](https://skydrive.live.com/), [Google Drive](http://drive.google.com),
9
+ [Google Drive](http://drive.google.com),
10
10
  [Box](http://www.box.com), [Amazon S3](https://aws.amazon.com/s3/),
11
11
  and a server-side directory share.
12
12
 
@@ -39,7 +39,7 @@ After installing the gem, run the generator
39
39
 
40
40
  This generator will set up the _config/browse_everything_providers.yml_ file and add the browse-everything engine to your application's routes.
41
41
 
42
- If you prefer not to use the generator, or need info on how to set up providers in the browse_everything_providers.yml, use the info on [Configuring browse-everything](https://github.com/projecthydra/browse-everything/wiki/Configuring-browse-everything).
42
+ If you prefer not to use the generator, or need info on how to set up providers in the browse_everything_providers.yml, use the info on [Configuring browse-everything](https://github.com/samvera/browse-everything/wiki/Configuring-browse-everything).
43
43
 
44
44
  ### Include the CSS and JavaScript
45
45
 
@@ -57,8 +57,8 @@ In `app/assets/javascripts/application.js` include jquery and the BrowseEverythi
57
57
 
58
58
  ### Adding Providers
59
59
  In order to connect to a provider like [Dropbox](http://www.dropbox.com),
60
- [Skydrive](https://skydrive.live.com/), [Google Drive](http://drive.google.com), or
61
- [Box](http://www.box.com), you must provide API keys in _config/browse_everything_providers.yml_. For info on how to edit this file, see [Configuring browse-everything](https://github.com/projecthydra/browse-everything/wiki/Configuring-browse-everything)
60
+ [Google Drive](http://drive.google.com), or
61
+ [Box](http://www.box.com), you must provide API keys in _config/browse_everything_providers.yml_. For info on how to edit this file, see [Configuring browse-everything](https://github.com/samvera/browse-everything/wiki/Configuring-browse-everything)
62
62
 
63
63
  ### Views
64
64
 
@@ -103,7 +103,7 @@ $('#browse').browseEverything({
103
103
  })
104
104
  ```
105
105
 
106
- See [JavaScript Methods](https://github.com/projecthydra/browse-everything/wiki/JavaScript-Methods) for more info on using javascript to trigger browse-everything.
106
+ See [JavaScript Methods](https://github.com/samvera/browse-everything/wiki/JavaScript-Methods) for more info on using javascript to trigger browse-everything.
107
107
 
108
108
  ### The Results (Data Structure)
109
109
 
@@ -133,7 +133,7 @@ If you initialized browse-everything via JavaScript, the results data passed to
133
133
  }
134
134
  ]
135
135
  ```
136
- See [JavaScript Methods](https://github.com/projecthydra/browse-everything/wiki/JavaScript-Methods) for more info on using javascript to trigger browse-everything.
136
+ See [JavaScript Methods](https://github.com/samvera/browse-everything/wiki/JavaScript-Methods) for more info on using javascript to trigger browse-everything.
137
137
 
138
138
  If you initialized browse-everything via data-attributes and set the _target_ option (via the _data-target_ attribute or via the _target_ option on the javascript method), the results data be written as hidden fields in the `<form>` you've specified as the target. When the user submits that form, the results will look like this:
139
139
  ```ruby
@@ -193,4 +193,4 @@ create a fully-functioning demo app in `spec/internal` (though you will have to
193
193
 
194
194
  ## Help
195
195
 
196
- For help with Questioning Authority, contact <hydra-tech@googlegroups.com>.
196
+ For help with Browse Everything, contact <samvera-tech@googlegroups.com>.
@@ -0,0 +1,17 @@
1
+ module FontAwesomeVersionHelper
2
+ def font_awesome_four?
3
+ Bundler.environment.specs['font-awesome-rails'].first.version >= Gem::Version.new('4')
4
+ end
5
+
6
+ def fa3(if3)
7
+ fa3or4(if3, '')
8
+ end
9
+
10
+ def fa4(if4)
11
+ fa3or4('', if4)
12
+ end
13
+
14
+ def fa3or4(if3, if4)
15
+ font_awesome_four? ? if4 : if3
16
+ end
17
+ end
@@ -1,26 +1,28 @@
1
- <% if bootstrap_three? %><div class="modal-dialog"><div class="modal-content"><% end %>
2
- <div class="modal-header">
3
- <h4 class="sr-only" id="beModalLabel">Select a provider in the list to browse your files.</h4>
4
- <div class="ev-providers">
5
- <%= render :partial => 'providers' %>
6
- </div>
7
- </div>
8
- <div class="modal-body ev-body" tabindex="-1">
9
- <div class="loading-progress" aria-live="assertive">
10
- <span class="loading-text">Loading...</span>
1
+ <div class="modal-dialog">
2
+ <div class="modal-content">
3
+ <div class="modal-header">
4
+ <h4 class="sr-only" id="beModalLabel">Select a provider in the list to browse your files.</h4>
5
+ <div class="ev-providers">
6
+ <%= render :partial => 'providers' %>
7
+ </div>
11
8
  </div>
12
- <div class="ev-browser row<%=bs2('-fluid')%>" aria-live="polite">
13
- <div class="<%=fa3or4('fa3','fa4')%> <%=bs2or3('bs2 span','bs3 col-xs-')%>12 ev-files list">
14
- <%= render :partial => 'files' if provider.present? %>
9
+ <div class="modal-body ev-body" tabindex="-1">
10
+ <div class="loading-progress" aria-live="assertive">
11
+ <span class="loading-text">Loading...</span>
12
+ </div>
13
+ <div class="ev-browser row" aria-live="polite">
14
+ <div class="<%=fa3or4('fa3','fa4')%> col-xs-12 ev-files list">
15
+ <%= render :partial => 'files' if provider.present? %>
16
+ </div>
15
17
  </div>
16
18
  </div>
19
+ <div class="modal-footer">
20
+ <span class="pull-left ev-status">0 files selected</span>
21
+ <%= form_tag '#', :class => "ev-submit-form form-horizontal", :data => { :resolver => browse_everything_engine.resolver_path } do %>
22
+ <input type="hidden" name="context" value=""/>
23
+ <button class="ev-cancel btn btn-danger"><%= t('browse_everything.modal_form.cancel')%></button>
24
+ <button class="ev-submit btn btn-primary" data-loading-text="Loading..."><%= t('browse_everything.modal_form.submit')%></button>
25
+ <% end %>
26
+ </div>
17
27
  </div>
18
- <div class="modal-footer">
19
- <span class="pull-left ev-status">0 files selected</span>
20
- <%= form_tag '#', :class => "ev-submit-form form-horizontal", :data => { :resolver => browse_everything_engine.resolver_path } do %>
21
- <input type="hidden" name="context" value=""/>
22
- <button class="ev-cancel btn btn-danger"><%= t('browse_everything.modal_form.cancel')%></button>
23
- <button class="ev-submit btn btn-primary" data-loading-text="Loading..."><%= t('browse_everything.modal_form.submit')%></button>
24
- <% end %>
25
- </div>
26
- <% if bootstrap_three? %></div></div><% end %>
28
+ </div>
@@ -22,15 +22,14 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'addressable', '~> 2.5'
23
23
  spec.add_dependency 'google_drive'
24
24
  spec.add_dependency 'dropbox-sdk', '>= 1.6.2'
25
- spec.add_dependency 'skydrive'
26
25
  spec.add_dependency 'ruby-box'
27
26
  spec.add_dependency 'sass-rails'
28
- spec.add_dependency 'bootstrap-sass'
27
+ spec.add_dependency 'bootstrap-sass', '~> 3.2'
29
28
  spec.add_dependency 'font-awesome-rails'
30
29
  spec.add_dependency 'google-api-client', '~> 0.9'
31
30
  spec.add_dependency 'signet'
32
31
  spec.add_dependency 'httparty'
33
- spec.add_dependency 'aws-sdk'
32
+ spec.add_dependency 'aws-sdk-s3'
34
33
  spec.add_development_dependency 'rspec', '~> 3.0'
35
34
  spec.add_development_dependency 'rspec-rails'
36
35
  spec.add_development_dependency 'rspec-its'
@@ -12,7 +12,6 @@ module BrowseEverything
12
12
  autoload :Base, 'browse_everything/driver/base'
13
13
  autoload :FileSystem, 'browse_everything/driver/file_system'
14
14
  autoload :Dropbox, 'browse_everything/driver/dropbox'
15
- autoload :SkyDrive, 'browse_everything/driver/sky_drive'
16
15
  autoload :Box, 'browse_everything/driver/box'
17
16
  autoload :GoogleDrive, 'browse_everything/driver/google_drive'
18
17
  autoload :S3, 'browse_everything/driver/s3'
@@ -1,4 +1,4 @@
1
- require 'aws-sdk'
1
+ require 'aws-sdk-s3'
2
2
 
3
3
  module BrowseEverything
4
4
  module Driver
@@ -1,3 +1,3 @@
1
1
  module BrowseEverything
2
- VERSION = '0.14.2'.freeze
2
+ VERSION = '0.15.0'.freeze
3
3
  end
@@ -18,6 +18,3 @@
18
18
  # :app_secret: YOUR_AWS_S3_SECRET # explicitly here, or left out to use system-configured
19
19
  # :region: YOUR_AWS_S3_REGION # defaults.
20
20
  # See https://aws.amazon.com/blogs/security/a-new-and-standardized-way-to-manage-credentials-in-the-aws-sdks/
21
- # sky_drive:
22
- # :client_id: YOUR_MS_LIVE_CONNECT_CLIENT_ID
23
- # :client_secret: YOUR_MS_LIVE_CONNECT_CLIENT_SECRET
@@ -60,10 +60,6 @@ module BrowserConfigHelper
60
60
  client_id: 'GoogleClientId',
61
61
  client_secret: 'GoogleClientSecret'
62
62
  },
63
- 'sky_drive' => {
64
- client_id: 'SkyDriveClientId',
65
- client_secret: 'SkyDriveClientSecret'
66
- },
67
63
  's3' => {
68
64
  app_key: 'S3AppKey',
69
65
  app_secret: 'S3AppSecret',
@@ -1,4 +1,4 @@
1
- <div class="<%=bs2or3('hero-unit','jumbotron')%>">
1
+ <div class="jumbotron">
2
2
  <h1>Welcome!</h1>
3
3
 
4
4
  <p>Please click the button below to start pickin' files!</p>
@@ -19,4 +19,4 @@
19
19
  .cancel(function() { window.alert('Canceled!') });
20
20
  });
21
21
  </script>
22
- </div>
22
+ </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browse-everything
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carolyn Cole
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2017-09-18 00:00:00.000000000 Z
16
+ date: 2017-10-11 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails
@@ -71,20 +71,6 @@ dependencies:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: 1.6.2
74
- - !ruby/object:Gem::Dependency
75
- name: skydrive
76
- requirement: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: '0'
81
- type: :runtime
82
- prerelease: false
83
- version_requirements: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
74
  - !ruby/object:Gem::Dependency
89
75
  name: ruby-box
90
76
  requirement: !ruby/object:Gem::Requirement
@@ -117,16 +103,16 @@ dependencies:
117
103
  name: bootstrap-sass
118
104
  requirement: !ruby/object:Gem::Requirement
119
105
  requirements:
120
- - - ">="
106
+ - - "~>"
121
107
  - !ruby/object:Gem::Version
122
- version: '0'
108
+ version: '3.2'
123
109
  type: :runtime
124
110
  prerelease: false
125
111
  version_requirements: !ruby/object:Gem::Requirement
126
112
  requirements:
127
- - - ">="
113
+ - - "~>"
128
114
  - !ruby/object:Gem::Version
129
- version: '0'
115
+ version: '3.2'
130
116
  - !ruby/object:Gem::Dependency
131
117
  name: font-awesome-rails
132
118
  requirement: !ruby/object:Gem::Requirement
@@ -184,7 +170,7 @@ dependencies:
184
170
  - !ruby/object:Gem::Version
185
171
  version: '0'
186
172
  - !ruby/object:Gem::Dependency
187
- name: aws-sdk
173
+ name: aws-sdk-s3
188
174
  requirement: !ruby/object:Gem::Requirement
189
175
  requirements:
190
176
  - - ">="
@@ -479,8 +465,8 @@ files:
479
465
  - app/assets/stylesheets/browse_everything/_browse_everything.scss
480
466
  - app/assets/stylesheets/jquery.treetable.theme.browse.css
481
467
  - app/controllers/browse_everything_controller.rb
482
- - app/helpers/bootstrap_version_helper.rb
483
468
  - app/helpers/browse_everything_helper.rb
469
+ - app/helpers/font_awesome_version_helper.rb
484
470
  - app/views/browse_everything/_auth.html.erb
485
471
  - app/views/browse_everything/_file.html.erb
486
472
  - app/views/browse_everything/_files.html.erb
@@ -502,7 +488,6 @@ files:
502
488
  - lib/browse_everything/driver/file_system.rb
503
489
  - lib/browse_everything/driver/google_drive.rb
504
490
  - lib/browse_everything/driver/s3.rb
505
- - lib/browse_everything/driver/sky_drive.rb
506
491
  - lib/browse_everything/engine.rb
507
492
  - lib/browse_everything/file_entry.rb
508
493
  - lib/browse_everything/retriever.rb
@@ -544,7 +529,6 @@ files:
544
529
  - spec/unit/file_system_spec.rb
545
530
  - spec/unit/retriever_spec.rb
546
531
  - spec/unit/s3_spec.rb
547
- - spec/unit/sky_drive_spec.rb
548
532
  - spec/views/browse_everything/_file.html.erb_spec.rb
549
533
  - tasks/ci.rake
550
534
  - vendor/assets/javascripts/jquery.treetable.js
@@ -570,7 +554,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
570
554
  version: '0'
571
555
  requirements: []
572
556
  rubyforge_project:
573
- rubygems_version: 2.5.1
557
+ rubygems_version: 2.6.13
574
558
  signing_key:
575
559
  specification_version: 4
576
560
  summary: AJAX/Rails engine file browser for cloud storage services
@@ -607,5 +591,4 @@ test_files:
607
591
  - spec/unit/file_system_spec.rb
608
592
  - spec/unit/retriever_spec.rb
609
593
  - spec/unit/s3_spec.rb
610
- - spec/unit/sky_drive_spec.rb
611
594
  - spec/views/browse_everything/_file.html.erb_spec.rb
@@ -1,33 +0,0 @@
1
- module BootstrapVersionHelper
2
- def bootstrap_three?
3
- Bundler.environment.specs['bootstrap-sass'].first.version >= Gem::Version.new('3')
4
- end
5
-
6
- def bs2(if2)
7
- bs2or3(if2, '')
8
- end
9
-
10
- def bs3(if3)
11
- bs2or3('', if3)
12
- end
13
-
14
- def bs2or3(if2, if3)
15
- bootstrap_three? ? if3 : if2
16
- end
17
-
18
- def font_awesome_four?
19
- Bundler.environment.specs['font-awesome-rails'].first.version >= Gem::Version.new('4')
20
- end
21
-
22
- def fa3(if3)
23
- fa3or4(if3, '')
24
- end
25
-
26
- def fa4(if4)
27
- fa3or4('', if4)
28
- end
29
-
30
- def fa3or4(if3, if4)
31
- font_awesome_four? ? if4 : if3
32
- end
33
- end
@@ -1,125 +0,0 @@
1
- module BrowseEverything
2
- module Driver
3
- class SkyDrive < Base
4
- require 'skydrive'
5
-
6
- def icon
7
- 'windows'
8
- end
9
-
10
- def container_items
11
- %w(folder album)
12
- end
13
-
14
- def validate_config
15
- unless config[:client_id]
16
- raise BrowseEverything::InitializationError, 'SkyDrive driver requires a :client_id argument'
17
- end
18
- unless config[:client_secret]
19
- raise BrowseEverything::InitializationError, 'SkyDrive driver requires a :client_secret argument'
20
- end
21
- end
22
-
23
- def contents(path = '')
24
- result = []
25
- token_obj = rehydrate_token
26
- client = Skydrive::Client.new(token_obj)
27
- if path == ''
28
- folder = client.my_skydrive
29
- # TODO: do some loop to get down to my path
30
- else
31
- folder = client.get("/#{path.tr('-', '.')}/")
32
- result += [parent_folder_details(folder)] if folder.parent_id
33
- end
34
-
35
- files = folder.files
36
- files.items.each do |item|
37
- if container_items.include? item.type
38
- result += [folder_details(item)]
39
- else
40
- Rails.logger.warn("\n\nID #{item.id} #{item.type}")
41
- result += [file_details(item)]
42
- end
43
- end
44
- result
45
- end
46
-
47
- def link_for(path)
48
- response = Skydrive::Client.new(rehydrate_token).get("/#{real_id(path)}/")
49
- [response.download_link, { expires: 1.hour.from_now, file_name: File.basename(path), file_size: response.size.to_i }]
50
- end
51
-
52
- def file_details(file)
53
- BrowseEverything::FileEntry.new(
54
- safe_id(file.id),
55
- "#{key}:#{safe_id(file.id)}",
56
- file.name,
57
- file.size,
58
- file.updated_time,
59
- false
60
- )
61
- end
62
-
63
- def parent_folder_details(file)
64
- BrowseEverything::FileEntry.new(
65
- safe_id(file.parent_id),
66
- "#{key}:#{safe_id(file.parent_id)}",
67
- '..',
68
- 0,
69
- Time.now,
70
- true
71
- )
72
- end
73
-
74
- def folder_details(folder)
75
- BrowseEverything::FileEntry.new(
76
- safe_id(folder.id),
77
- "#{key}:#{safe_id(folder.id)}",
78
- folder.name,
79
- 0,
80
- folder.updated_time,
81
- true,
82
- 'directory' # TODO: how are we getting mime type
83
- )
84
- end
85
-
86
- def auth_link
87
- oauth_client.authorize_url
88
- end
89
-
90
- def authorized?
91
- return false unless @token.present?
92
- !rehydrate_token.expired?
93
- end
94
-
95
- def connect(params, _data)
96
- Rails.logger.warn "params #{params.inspect}"
97
- token = oauth_client.get_access_token(params[:code])
98
- @token = { token: token.token, expires_at: token.expires_at }
99
- end
100
-
101
- private
102
-
103
- def oauth_client
104
- Skydrive::Oauth::Client.new(config[:client_id], config[:client_secret], callback.to_s, 'wl.skydrive')
105
- # TODO: error checking here
106
- end
107
-
108
- def rehydrate_token
109
- return @rehydrate_token if @rehydrate_token
110
- token_str = @token[:token]
111
- token_expires = @token[:expires_at]
112
- Rails.logger.warn "\n\n Rehydrating: #{@token} #{token_str} #{token_expires}"
113
- @rehydrate_token = oauth_client.get_access_token_from_hash(token_str, expires_at: token_expires)
114
- end
115
-
116
- def safe_id(id)
117
- id.tr('.', '-')
118
- end
119
-
120
- def real_id(id)
121
- id.tr('-', '.')
122
- end
123
- end
124
- end
125
- end
@@ -1,65 +0,0 @@
1
- describe BrowseEverything::Driver::SkyDrive do
2
- include BrowseEverything::Engine.routes.url_helpers
3
-
4
- let(:provider_yml) do
5
- {
6
- client_id: 'CLIENTID', client_secret: 'CLIENTSECRET',
7
- url_options: { port: '3000', protocol: 'http://', host: 'example.com' }
8
- }
9
- end
10
-
11
- let(:redirect_url) { connector_response_url(provider_yml[:url_options]) }
12
-
13
- let(:response_body) do
14
- {
15
- 'client_id' => 'CLIENTID', 'client_secret' => 'CLIENTSECRET', 'code' => 'code',
16
- 'grant_type' => 'authorization_code', 'redirect_uri' => redirect_url.to_s
17
- }
18
- end
19
-
20
- let(:driver) { described_class.new(provider_yml) }
21
-
22
- subject { driver }
23
-
24
- context 'when expiration is in the future' do
25
- before do
26
- stub_request(:post, 'https://login.live.com/oauth20_token.srf')
27
- .with(body: response_body)
28
- .to_return(status: 200,
29
- body: {
30
- 'token_type' => 'bearer',
31
- 'expires_at' => (Time.now + (60 * 60 * 24)).to_i,
32
- 'scope' => 'wl.skydrive_update,wl.offline_access',
33
- 'access_token' => 'access_token',
34
- 'refresh_token' => 'refresh_token',
35
- 'authentication_token' => 'authentication_token'
36
- }.to_json,
37
- headers: {
38
- 'content-type' => 'application/json' })
39
- driver.connect({ code: 'code' }, {})
40
- end
41
-
42
- it { is_expected.to be_authorized }
43
- end
44
-
45
- context 'when the session has expired' do
46
- before do
47
- stub_request(:post, 'https://login.live.com/oauth20_token.srf')
48
- .with(body: response_body)
49
- .to_return(status: 200,
50
- body: {
51
- 'token_type' => 'bearer',
52
- 'expires_at' => (Time.now - (60 * 60 * 24)).to_i,
53
- 'scope' => 'wl.skydrive_update,wl.offline_access',
54
- 'access_token' => 'access_token',
55
- 'refresh_token' => 'refresh_token',
56
- 'authentication_token' => 'authentication_token'
57
- }.to_json,
58
- headers: {
59
- 'content-type' => 'application/json' })
60
- driver.connect({ code: 'code' }, {})
61
- end
62
-
63
- it { is_expected.not_to be_authorized }
64
- end
65
- end