Merge branch 'master' into glitch-soc/merge-upstream

Conflicts:
- README.md
  discarded upstream changes
- app/controllers/api/v1/bookmarks_controller.rb
  finally merged upstream, some code style fixes
  and slightly changed pagination code
- app/controllers/application_controller.rb
  changed upstream to always return HTML error pages
  slight conflict caused by theming code
- app/models/bookmark.rb
  finally merged upstream, no real conflict
- spec/controllers/api/v1/bookmarks_controller_spec.rb
  finally merged upstream, slightly changed pagination code
This commit is contained in:
Thibaut Girka
2019-11-20 15:36:09 +01:00
953 changed files with 9201 additions and 2699 deletions

View File

@@ -59,6 +59,19 @@ describe Api::V1::Accounts::CredentialsController do
end
end
describe 'with empty source list' do
before do
patch :update, params: {
display_name: "I'm a cat",
source: {},
}, as: :json
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
end
describe 'with invalid data' do
before do
note = 'This is too long. '

View File

@@ -64,7 +64,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do
get :index, params: { limit: 1 }
expect(response.headers['Link'].find_link(['rel', 'next']).href).to eq "http://test.host/api/v1/bookmarks?limit=1&max_id=#{bookmark.id}"
expect(response.headers['Link'].find_link(['rel', 'prev']).href).to eq "http://test.host/api/v1/bookmarks?limit=1&since_id=#{bookmark.id}"
expect(response.headers['Link'].find_link(['rel', 'prev']).href).to eq "http://test.host/api/v1/bookmarks?limit=1&min_id=#{bookmark.id}"
end
it 'does not add pagination headers if not necessary' do

View File

@@ -22,11 +22,6 @@ describe ApplicationController, type: :controller do
end
shared_examples 'respond_with_error' do |code|
it "returns http #{code} for any" do
subject
expect(response).to have_http_status(code)
end
it "returns http #{code} for http" do
subject
expect(response).to have_http_status(code)

View File

@@ -26,6 +26,7 @@ describe 'Localization' do
I18n.t('about.tagline', locale: 'es')
)
end
it 'falls back to english when locale is missing' do
headers = { 'Accept-Language' => '12-FAKE' }

View File

@@ -113,6 +113,24 @@ describe FetchOEmbedService, type: :service do
end
context 'when endpoint is cached' do
before do
stub_request(:get, 'http://www.youtube.com/oembed?format=json&url=https://www.youtube.com/watch?v=dqwpQarrDwk').to_return(
status: 200,
headers: { 'Content-Type': 'text/html' },
body: request_fixture('oembed_json_empty.html')
)
end
it 'returns new provider without fetching original URL first' do
subject.call('https://www.youtube.com/watch?v=dqwpQarrDwk', cached_endpoint: { endpoint: 'http://www.youtube.com/oembed?format=json&url={url}', format: :json })
expect(a_request(:get, 'https://www.youtube.com/watch?v=dqwpQarrDwk')).to_not have_been_made
expect(subject.endpoint_url).to eq 'http://www.youtube.com/oembed?format=json&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdqwpQarrDwk'
expect(subject.format).to eq :json
expect(a_request(:get, 'http://www.youtube.com/oembed?format=json&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdqwpQarrDwk')).to have_been_made
end
end
context 'when status code is not 200' do
before do
stub_request(:get, 'https://host.test/oembed.html').to_return(

View File

@@ -12,6 +12,7 @@ end
gc_counter = -1
RSpec.configure do |config|
config.example_status_persistence_file_path = ".cache/rspec"
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end