diff --git a/api_coverage.md b/api_coverage.md index 51bcf803..018d3c71 100644 --- a/api_coverage.md +++ b/api_coverage.md @@ -68,7 +68,7 @@ API call | Status `/restore` | 🌕 `/save_url` | 🌕 `/save_url/check_job_status` | 🌕 -`/search` | 🌔 +`/search_v2` | 🌔 `/upload` | 🌕 `/upload_session/append` | alias? `/upload_session/append_v2` | 🌕 diff --git a/lib/dropbox_api.rb b/lib/dropbox_api.rb index 35fb4e54..24aef6de 100644 --- a/lib/dropbox_api.rb +++ b/lib/dropbox_api.rb @@ -41,6 +41,16 @@ require 'dropbox_api/metadata/folder' require 'dropbox_api/metadata/deleted' require 'dropbox_api/metadata/resource' +require 'dropbox_api/metadata/metadata_v2' +require 'dropbox_api/metadata/file_category' +require 'dropbox_api/metadata/file_categories_list' +require 'dropbox_api/metadata/file_extensions_list' +require 'dropbox_api/metadata/search_order_by' +require 'dropbox_api/metadata/file_status' +require 'dropbox_api/metadata/search_options' +require 'dropbox_api/metadata/search_match_type_v2' +require 'dropbox_api/metadata/search_match_v2' +require 'dropbox_api/metadata/search_match_field_options' require 'dropbox_api/metadata/shared_folder_policy' require 'dropbox_api/metadata/shared_folder' require 'dropbox_api/metadata/file_link_metadata' @@ -126,8 +136,7 @@ require 'dropbox_api/results/list_shared_links_result' require 'dropbox_api/results/save_url_result' require 'dropbox_api/results/save_url_job_status' -require 'dropbox_api/results/search/match' -require 'dropbox_api/results/search_result' +require 'dropbox_api/results/search_v2_result' require 'dropbox_api/results/share_folder_launch' require 'dropbox_api/results/shared_file_members' require 'dropbox_api/results/shared_folder_members' diff --git a/lib/dropbox_api/endpoints/files/search.rb b/lib/dropbox_api/endpoints/files/search.rb index ed302bdf..be872fc3 100644 --- a/lib/dropbox_api/endpoints/files/search.rb +++ b/lib/dropbox_api/endpoints/files/search.rb @@ -2,12 +2,8 @@ module DropboxApi::Endpoints::Files class Search < DropboxApi::Endpoints::Rpc Method = :post -<<<<<<< HEAD - Path = '/2/files/search' -======= Path = '/2/files/search_v2' ->>>>>>> add search_v2 url support - ResultType = DropboxApi::Results::SearchResult + ResultType = DropboxApi::Results::SearchV2Result ErrorType = DropboxApi::Errors::SearchError include DropboxApi::OptionsValidator @@ -17,32 +13,20 @@ class Search < DropboxApi::Endpoints::Rpc # Note: Recent changes may not immediately be reflected in search results # due to a short delay in indexing. # - # @param query [String] The string to search for. The search string is - # split on spaces into multiple tokens. For file name searching, the last - # token is used for prefix matching (i.e. "bat c" matches "bat cave" but - # not "batman car"). - # @param path [String] The path in the user's Dropbox to search. - # @option options start [Numeric] The starting index within the search - # results (used for paging). The default for this field is 0. - # @option options max_results [Numeric] The maximum number of search - # results to return. The default for this field is 100. - # @option options mode [:filename, :filename_and_content, :deleted_filename] - # The search mode. Note that searching file content is only - # available for Dropbox Business accounts. The default is filename. - add_endpoint :search do |query, path = '', options = {}| - validate_options([ - :start, - :max_results, - :mode - ], options) - options[:start] ||= 0 - options[:max_results] ||= 100 - options[:mode] ||= :filename + # @param query [String] The string to search for. May match across + # multiple fields based on the request arguments. + # @param options [DropboxApi::Metadata::SearchOptions] Options for more + # targeted search results. This field is optional. + # @param match_field_options [DropboxApi::Metadata::SearchMatchFieldOptions] + # Options for search results match fields. This field is optional. + add_endpoint :search do |query, options = nil, match_field_options = nil| + params = { query: query } - perform_request options.merge({ - query: query, - path: path - }) + params[:options] = options.to_hash unless options.nil? + + params[:match_field_options] = match_field_options.to_hash unless match_field_options.nil? + + perform_request(params) end end end diff --git a/lib/dropbox_api/metadata/field.rb b/lib/dropbox_api/metadata/field.rb index 3140f29a..c9567f76 100644 --- a/lib/dropbox_api/metadata/field.rb +++ b/lib/dropbox_api/metadata/field.rb @@ -28,10 +28,12 @@ def force_cast(object) object['.tag'].to_sym elsif @type == :boolean object.to_s == 'true' - elsif @type.ancestors.include? DropboxApi::Metadata::Base + elsif @type.ancestors.include?(DropboxApi::Metadata::Base) || + @type.ancestors.include?(Array) || + @type == DropboxApi::Metadata::Resource @type.new(object) else - raise NotImplementedError, "Can't cast `#{@type}`" + raise NotImplementedError, "Can't cast #{object} to `#{@type}`" end end end diff --git a/lib/dropbox_api/metadata/file_categories_list.rb b/lib/dropbox_api/metadata/file_categories_list.rb new file mode 100644 index 00000000..2a2bdae4 --- /dev/null +++ b/lib/dropbox_api/metadata/file_categories_list.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class FileCategoriesList < Array + def initialize(list) + super(list.map { |c| DropboxApi::Metadata::FileCategory.new c }) + end + end +end diff --git a/lib/dropbox_api/metadata/file_category.rb b/lib/dropbox_api/metadata/file_category.rb new file mode 100644 index 00000000..a15ffd83 --- /dev/null +++ b/lib/dropbox_api/metadata/file_category.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class FileCategory < DropboxApi::Metadata::Tag + VALID_VALUES = %i[ + image + document + pdf + spreadsheet + presentation + audio + video + folder + paper + others + ].freeze + + def self.valid_values + VALID_VALUES + end + end +end diff --git a/lib/dropbox_api/metadata/file_extensions_list.rb b/lib/dropbox_api/metadata/file_extensions_list.rb new file mode 100644 index 00000000..218465b5 --- /dev/null +++ b/lib/dropbox_api/metadata/file_extensions_list.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class FileExtensionsList < Array + def initialize(data) + if !data.is_a?(Array) || data.any? { |v| !v.is_a? String } + raise ArgumentError, "Invalid extension list: #{data.inspect}." + end + + super(data) + end + end +end diff --git a/lib/dropbox_api/metadata/file_status.rb b/lib/dropbox_api/metadata/file_status.rb new file mode 100644 index 00000000..b04fe8e1 --- /dev/null +++ b/lib/dropbox_api/metadata/file_status.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class FileStatus < DropboxApi::Metadata::Tag + VALID_VALUES = %i[ + active + deleted + ].freeze + + def self.valid_values + VALID_VALUES + end + end +end diff --git a/lib/dropbox_api/metadata/metadata_v2.rb b/lib/dropbox_api/metadata/metadata_v2.rb new file mode 100644 index 00000000..21d0b780 --- /dev/null +++ b/lib/dropbox_api/metadata/metadata_v2.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class MetadataV2 < Base + field :metadata, DropboxApi::Metadata::Resource + end +end diff --git a/lib/dropbox_api/metadata/search_match_field_options.rb b/lib/dropbox_api/metadata/search_match_field_options.rb new file mode 100644 index 00000000..f04b2582 --- /dev/null +++ b/lib/dropbox_api/metadata/search_match_field_options.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class SearchMatchFieldOptions < Base + # Whether to include highlight span from file title. The default for + # this field is False. + field :include_highlights, :boolean, :optional + end +end diff --git a/lib/dropbox_api/metadata/search_match_type_v2.rb b/lib/dropbox_api/metadata/search_match_type_v2.rb new file mode 100644 index 00000000..f797fc3b --- /dev/null +++ b/lib/dropbox_api/metadata/search_match_type_v2.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class SearchMatchTypeV2 < DropboxApi::Metadata::Tag + VALID_VALUES = %i[ + filename + file_content + filename_and_content + image_content + ].freeze + + def self.valid_values + VALID_VALUES + end + end +end diff --git a/lib/dropbox_api/metadata/search_match_v2.rb b/lib/dropbox_api/metadata/search_match_v2.rb new file mode 100644 index 00000000..ace95b92 --- /dev/null +++ b/lib/dropbox_api/metadata/search_match_v2.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class SearchMatchV2 < Base + # The metadata for the matched file or folder. + field :metadata, DropboxApi::Metadata::MetadataV2 + + # The type of the match. This field is optional. + field :match_type, SearchMatchTypeV2 + + def resource + # for some strange reason, v2 of this search endpoint doesn't have + # the `resource` field anymore and file metadata is wrapped in a + # metadata/metadata field... + metadata.metadata + end + end +end diff --git a/lib/dropbox_api/metadata/search_options.rb b/lib/dropbox_api/metadata/search_options.rb new file mode 100644 index 00000000..746b177a --- /dev/null +++ b/lib/dropbox_api/metadata/search_options.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class SearchOptions < Base + # Scopes the search to a path in the user's Dropbox. Searches the entire + # Dropbox if not specified. This field is optional. + field :path, String, :optional + + # The maximum number of search results to return. The default for this + # field is 100. + field :max_results, Integer, :optional + + # Specified property of the order of search results. By default, results + # are sorted by relevance. This field is optional. + field :order_by, DropboxApi::Metadata::SearchOrderBy, :optional + + # Restricts search to the given file status. The default for this union + # is active. + field :file_status, DropboxApi::Metadata::FileStatus, :optional + + # Restricts search to only match on filenames. The default for this field + # is false. + field :filename_only, :boolean, :optional + + # Restricts search to only the extensions specified. Only supported for + # active file search. This field is optional. + field :file_extensions, DropboxApi::Metadata::FileExtensionsList, :optional + + # Restricts search to only the file categories specified. Only supported + # for active file search. This field is optional. + field :file_categories, DropboxApi::Metadata::FileCategoriesList, :optional + end +end diff --git a/lib/dropbox_api/metadata/search_order_by.rb b/lib/dropbox_api/metadata/search_order_by.rb new file mode 100644 index 00000000..4d9e9467 --- /dev/null +++ b/lib/dropbox_api/metadata/search_order_by.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module DropboxApi::Metadata + class SearchOrderBy < DropboxApi::Metadata::Tag + VALID_VALUES = %i[ + relevance + last_modified_time + ].freeze + + def self.valid_values + VALID_VALUES + end + end +end diff --git a/lib/dropbox_api/results/search_result.rb b/lib/dropbox_api/results/search_v2_result.rb similarity index 59% rename from lib/dropbox_api/results/search_result.rb rename to lib/dropbox_api/results/search_v2_result.rb index 2c7de956..a847c196 100644 --- a/lib/dropbox_api/results/search_result.rb +++ b/lib/dropbox_api/results/search_v2_result.rb @@ -1,23 +1,24 @@ # frozen_string_literal: true module DropboxApi::Results - class SearchResult < DropboxApi::Results::Base + class SearchV2Result < DropboxApi::Results::Base # A list (possibly empty) of matches for the query. def matches @matches ||= @data['matches'].map do |match| - DropboxApi::Results::Search::Match.new match + DropboxApi::Metadata::SearchMatchV2.new match end end - # Used for paging. Value to set the start argument to when calling search - # to fetch the next page of results. - def start - @data['start'].to_i - end - # Used for paging. If true, indicates there is another page of results # available that can be fetched by calling search again. def has_more? @data['more'].to_s == 'true' end + + # Pass the cursor into #search_continue to fetch the next page of results + # (not yet implemented). + # This field is optional. + def cursor + @data['cursor'] + end end end diff --git a/spec/endpoints/files/search_spec.rb b/spec/endpoints/files/search_spec.rb index 4b76639f..ad27e4f7 100644 --- a/spec/endpoints/files/search_spec.rb +++ b/spec/endpoints/files/search_spec.rb @@ -5,16 +5,21 @@ end it 'returns a list of matching results', cassette: 'search/success' do - result = @client.search('image.png') + result = @client.search('findable_file') - expect(result).to be_a(DropboxApi::Results::SearchResult) - file = result.matches.first.resource - expect(file.name).to eq('image.png') + expect(result).to be_a(DropboxApi::Results::SearchV2Result) + match = result.matches.first + expect(match.resource.name).to eq('findable_file.txt') + expect(match.match_type).to eq(:filename) end - it "raises an error if the file can't be found", cassette: 'search/not_found' do - expect { - @client.search('/image.png', '/bad_folder') - }.to raise_error(DropboxApi::Errors::NotFoundError) + it "raises an error if the file can't be found", + cassette: 'search/not_found' do + options = DropboxApi::Metadata::SearchOptions.new( + { 'path' => '/bad_folder' } + ) + + result = @client.search('/image.png', options) + expect(result.matches).to be_empty end end diff --git a/spec/fixtures/vcr_cassettes/search/not_found.yml b/spec/fixtures/vcr_cassettes/search/not_found.yml index d5b81ba8..49b1a083 100644 --- a/spec/fixtures/vcr_cassettes/search/not_found.yml +++ b/spec/fixtures/vcr_cassettes/search/not_found.yml @@ -5,12 +5,12 @@ http_interactions: uri: https://api.dropboxapi.com/2/files/search_v2 body: encoding: UTF-8 - string: '{"start":0,"max_results":100,"mode":"filename","query":"/image.png","path":"/bad_folder"}' + string: '{"query":"/image.png","options":{"path":"/bad_folder"}}' headers: Authorization: - Bearer MOCK_AUTHORIZATION_BEARER User-Agent: - - Faraday v0.9.2 + - Faraday v1.3.0 Content-Type: - application/json Accept-Encoding: @@ -19,25 +19,39 @@ http_interactions: - "*/*" response: status: - code: 409 - message: Conflict + code: 200 + message: OK headers: - Server: - - nginx - Date: - - Sat, 04 Jun 2016 08:36:27 GMT + Cache-Control: + - no-cache + Content-Disposition: + - attachment + Content-Security-Policy: + - sandbox Content-Type: - application/json + Date: + - Sun, 07 Feb 2021 10:30:27 GMT + Pragma: + - no-cache + X-Content-Security-Policy: + - sandbox + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - sameorigin + X-Server-Response-Time: + - '54' + X-Webkit-Csp: + - sandbox Content-Length: - - '96' - Connection: - - keep-alive + - '31' + Server: + - envoy X-Dropbox-Request-Id: - - 8b9426d8c961e5d6d22c78da4d22080e + - a0547acb22a84f57aac28978892f0fb0 body: encoding: UTF-8 - string: '{"error_summary": "path/not_found/..", "error": {".tag": "path", "path": - {".tag": "not_found"}}}' - http_version: - recorded_at: Sat, 04 Jun 2016 08:36:27 GMT -recorded_with: VCR 3.0.1 + string: '{"has_more":false,"matches":[]}' + recorded_at: Sun, 07 Feb 2021 10:30:27 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/vcr_cassettes/search/success.yml b/spec/fixtures/vcr_cassettes/search/success.yml index 6ec97180..53df215c 100644 --- a/spec/fixtures/vcr_cassettes/search/success.yml +++ b/spec/fixtures/vcr_cassettes/search/success.yml @@ -5,12 +5,12 @@ http_interactions: uri: https://api.dropboxapi.com/2/files/search_v2 body: encoding: UTF-8 - string: '{"start":0,"max_results":100,"mode":"filename","query":"image.png","path":""}' + string: '{"query":"findable_file"}' headers: Authorization: - Bearer MOCK_AUTHORIZATION_BEARER User-Agent: - - Faraday v0.9.2 + - Faraday v1.3.0 Content-Type: - application/json Accept-Encoding: @@ -22,40 +22,38 @@ http_interactions: code: 200 message: OK headers: - Server: - - nginx - Date: - - Sat, 04 Jun 2016 08:36:26 GMT - Content-Type: - - application/json - Content-Length: - - '346' - Connection: - - keep-alive Cache-Control: - no-cache + Content-Disposition: + - attachment + Content-Security-Policy: + - sandbox + Content-Type: + - application/json + Date: + - Sun, 07 Feb 2021 10:30:26 GMT Pragma: - no-cache - Set-Cookie: - - gvc=NjQ4NjA3NTk0Njg0MzA1MjA3MzgxMDY2NDA0MTQ0MzcxMTAyNjQ%3D; expires=Thu, 03 - Jun 2021 08:36:26 GMT; httponly; Path=/; secure + X-Content-Security-Policy: + - sandbox X-Content-Type-Options: - nosniff - X-Dropbox-Http-Protocol: - - None X-Frame-Options: - - SAMEORIGIN + - sameorigin X-Server-Response-Time: - - '156' + - '160' + X-Webkit-Csp: + - sandbox + Server: + - envoy + Vary: + - Accept-Encoding X-Dropbox-Request-Id: - - 0962978b76ee3f37ca90f918f3ad49b6 + - a0b2671f184943e1916d17d69b4d5ce0 + Transfer-Encoding: + - chunked body: - encoding: UTF-8 - string: '{"matches": [{"match_type": {".tag": "filename"}, "metadata": {".tag": - "file", "name": "image.png", "path_lower": "/image.png", "path_display": "/image.png", - "id": "id:jVVdzRI3CnAAAAAAAAAAAQ", "client_modified": "2016-05-22T09:29:22Z", - "server_modified": "2016-06-04T08:36:02Z", "rev": "1a4524061bdd", "size": - 77019}}], "more": false, "start": 1}' - http_version: - recorded_at: Sat, 04 Jun 2016 08:36:26 GMT -recorded_with: VCR 3.0.1 + encoding: ASCII-8BIT + string: '{"has_more":false,"matches":[{"match_type":{".tag":"filename"},"metadata":{".tag":"metadata","metadata":{".tag":"file","client_modified":"2021-02-07T10:29:47Z","content_hash":"ddc458cb9f13e2e9f4b02a579cc752c8bbcbb7fdfd4c54faea8e98b7f4b80ea8","id":"id:L5U1_AOVa-QAAAAAAAA4sA","is_downloadable":true,"name":"findable_file.txt","path_display":"/dropbox_api_fixtures/search/findable_file.txt","path_lower":"/dropbox_api_fixtures/search/findable_file.txt","rev":"5babc88636b60043720ae","server_modified":"2021-02-07T10:29:48Z","size":4}}}]}' + recorded_at: Sun, 07 Feb 2021 10:30:27 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/metadata/file_categories_list_spec.rb b/spec/metadata/file_categories_list_spec.rb new file mode 100644 index 00000000..d842138d --- /dev/null +++ b/spec/metadata/file_categories_list_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +context DropboxApi::Metadata::FileCategoriesList do + it 'can be initialized empty' do + list = DropboxApi::Metadata::FileCategoriesList.new([]) + + expect(list).to be_a(Array) + end + + it 'can be initialized with some categories' do + list = DropboxApi::Metadata::FileCategoriesList.new(%w[pdf image]) + + expect(list).to be_a(Array) + expect(list).to include(:pdf) + expect(list).to include(:image) + end + + it 'raises if extensions have an invalid value' do + expect do + DropboxApi::Metadata::FileCategoriesList.new(['game']) + end.to raise_error(ArgumentError) + end +end diff --git a/spec/metadata/file_extensions_list_spec.rb b/spec/metadata/file_extensions_list_spec.rb new file mode 100644 index 00000000..75ad9bec --- /dev/null +++ b/spec/metadata/file_extensions_list_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +context DropboxApi::Metadata::FileExtensionsList do + it 'can be initialized empty' do + list = DropboxApi::Metadata::FileExtensionsList.new([]) + + expect(list).to be_a(Array) + end + + it 'can be initialized with some extensions' do + list = DropboxApi::Metadata::FileExtensionsList.new(%w[jpg png xcf]) + + expect(list).to be_a(Array) + expect(list).to include('jpg') + expect(list).to include('png') + expect(list).to include('xcf') + end + + it 'raises if extensions have an invalid value' do + expect do + DropboxApi::Metadata::FileExtensionsList.new([1, 2, 3]) + end.to raise_error(ArgumentError) + end +end diff --git a/spec/metadata/file_status_spec.rb b/spec/metadata/file_status_spec.rb new file mode 100644 index 00000000..c4cee055 --- /dev/null +++ b/spec/metadata/file_status_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +context DropboxApi::Metadata::FileStatus do + it 'can be initialized from a symbol' do + option = DropboxApi::Metadata::FileStatus.new :active + + expect(option).to eq(:active) + end + + it 'raises if initialized with an invalid value' do + expect do + DropboxApi::Metadata::FileStatus.new :invalid + end.to raise_error(ArgumentError) + end +end diff --git a/spec/metadata/search_match_field_options_spec.rb b/spec/metadata/search_match_field_options_spec.rb new file mode 100644 index 00000000..198b3f53 --- /dev/null +++ b/spec/metadata/search_match_field_options_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +context DropboxApi::Metadata::SearchMatchFieldOptions do + it 'can be initialized empty' do + options = DropboxApi::Metadata::SearchMatchFieldOptions.new({}) + + expect(options).to be_a(DropboxApi::Metadata::SearchMatchFieldOptions) + expect(options.to_hash).to eq({}) + end + + it 'can be initialized and set to include highlights' do + options = DropboxApi::Metadata::SearchMatchFieldOptions.new({ 'include_highlights' => true }) + + expect(options).to be_a(DropboxApi::Metadata::SearchMatchFieldOptions) + expect(options.include_highlights).to be_truthy + end +end diff --git a/spec/metadata/search_options_spec.rb b/spec/metadata/search_options_spec.rb new file mode 100644 index 00000000..94a2c855 --- /dev/null +++ b/spec/metadata/search_options_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +context DropboxApi::Metadata::SearchOptions do + it 'can be initialized empty' do + options = DropboxApi::Metadata::SearchOptions.new({}) + + expect(options).to be_a(DropboxApi::Metadata::SearchOptions) + expect(options.to_hash).to eq({}) + end + + it 'can be initialized with path' do + options = DropboxApi::Metadata::SearchOptions.new({ 'path' => '/folder' }) + + expect(options).to be_a(DropboxApi::Metadata::SearchOptions) + expect(options.path).to eq('/folder') + end + + it 'can be initialized with several values' do + options = DropboxApi::Metadata::SearchOptions.new( + { + 'path' => '/folder', + 'max_results' => 42, + 'file_status' => :deleted, + 'filename_only' => true, + 'file_extensions' => %w[jpg png], + 'file_categories' => %w[folder paper] + } + ) + + expect(options).to be_a(DropboxApi::Metadata::SearchOptions) + expect(options.path).to eq('/folder') + expect(options.max_results).to eq(42) + expect(options.file_status).to eq(:deleted) + expect(options.filename_only).to eq(true) + end +end diff --git a/spec/metadata/search_order_by_spec.rb b/spec/metadata/search_order_by_spec.rb new file mode 100644 index 00000000..dfda466a --- /dev/null +++ b/spec/metadata/search_order_by_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +context DropboxApi::Metadata::SearchOrderBy do + it 'can be initialized from a symbol' do + option = DropboxApi::Metadata::SearchOrderBy.new :relevance + + expect(option).to eq(:relevance) + end + + it 'raises if initialized with an invalid value' do + expect do + DropboxApi::Metadata::SearchOrderBy.new :invalid + end.to raise_error(ArgumentError) + end +end diff --git a/spec/support/dropbox_scaffold_builder.rb b/spec/support/dropbox_scaffold_builder.rb index ee4910be..4c49ef27 100644 --- a/spec/support/dropbox_scaffold_builder.rb +++ b/spec/support/dropbox_scaffold_builder.rb @@ -116,6 +116,10 @@ def build_get_shared_link_metadata client.create_shared_link_with_settings("#{path_prefix}/shared_file.txt") end + def build_search + client.upload("#{path_prefix}/findable_file.txt", 'Moo.') + end + # We have a prefix for each endpoint to avoid conflicts across them def path_prefix File.join PREFIX, @endpoint_name