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

Conflicts:
	db/migrate/20170716191202_add_hide_notifications_to_mute.rb
	spec/controllers/application_controller_spec.rb

Took our version, upstream changes were only minor style linting.
This commit is contained in:
Thibaut Girka
2018-10-05 15:23:57 +02:00
93 changed files with 406 additions and 324 deletions

View File

@ -3,8 +3,8 @@ require 'rails_helper'
RSpec.describe AccountsController, type: :controller do
render_views
let(:alice) { Fabricate(:account, username: 'alice') }
let(:eve) { Fabricate(:user) }
let(:alice) { Fabricate(:account, username: 'alice') }
let(:eve) { Fabricate(:user) }
describe 'GET #show' do
let!(:status1) { Status.create!(account: alice, text: 'Hello world') }

View File

@ -25,7 +25,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
expect(h[:remote]).to eq '1'
expect(h[:by_domain]).to eq 'domain'
expect(h[:silenced]).to eq '1'
expect(h[:recent]).to eq '1'
expect(h[:alphabetic]).to eq '1'
expect(h[:suspended]).to eq '1'
expect(h[:username]).to eq 'username'
expect(h[:display_name]).to eq 'display name'
@ -40,7 +40,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
remote: '1',
by_domain: 'domain',
silenced: '1',
recent: '1',
alphabetic: '1',
suspended: '1',
username: 'username',
display_name: 'display name',
@ -75,7 +75,6 @@ RSpec.describe Admin::AccountsController, type: :controller do
end
end
describe 'POST #subscribe' do
subject { post :subscribe, params: { id: account.id } }

View File

@ -40,7 +40,7 @@ RSpec.describe Admin::EmailDomainBlocksController, type: :controller do
describe 'POST #create' do
it 'blocks the domain when succeeded to save' do
post :create, params: { email_domain_block: { domain: 'example.com'} }
post :create, params: { email_domain_block: { domain: 'example.com' } }
expect(flash[:notice]).to eq I18n.t('admin.email_domain_blocks.created_msg')
expect(response).to redirect_to(admin_email_domain_blocks_path)
@ -50,7 +50,7 @@ RSpec.describe Admin::EmailDomainBlocksController, type: :controller do
describe 'DELETE #destroy' do
it 'unblocks the domain' do
email_domain_block = Fabricate(:email_domain_block)
delete :destroy, params: { id: email_domain_block.id }
delete :destroy, params: { id: email_domain_block.id }
expect(flash[:notice]).to eq I18n.t('admin.email_domain_blocks.destroyed_msg')
expect(response).to redirect_to(admin_email_domain_blocks_path)

View File

@ -24,7 +24,7 @@ describe Admin::InvitesController do
subject { post :create, params: { invite: { max_uses: '10', expires_in: 1800 } } }
it 'succeeds to create a invite' do
expect{ subject }.to change { Invite.count }.by(1)
expect { subject }.to change { Invite.count }.by(1)
expect(subject).to redirect_to admin_invites_path
expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10)
end

View File

@ -15,7 +15,6 @@ describe Admin::ReportNotesController do
let(:report) { Fabricate(:report, action_taken: action_taken, action_taken_by_account_id: account_id) }
context 'when parameter is valid' do
context 'when report is unsolved' do
let(:action_taken) { false }
let(:account_id) { nil }
@ -24,7 +23,7 @@ describe Admin::ReportNotesController do
let(:params) { { report_note: { content: 'test content', report_id: report.id }, create_and_resolve: nil } }
it 'creates a report note and resolves report' do
expect{ subject }.to change{ ReportNote.count }.by(1)
expect { subject }.to change { ReportNote.count }.by(1)
expect(report.reload).to be_action_taken
expect(subject).to redirect_to admin_reports_path
end
@ -34,7 +33,7 @@ describe Admin::ReportNotesController do
let(:params) { { report_note: { content: 'test content', report_id: report.id } } }
it 'creates a report note and does not resolve report' do
expect{ subject }.to change{ ReportNote.count }.by(1)
expect { subject }.to change { ReportNote.count }.by(1)
expect(report.reload).not_to be_action_taken
expect(subject).to redirect_to admin_report_path(report)
end
@ -49,7 +48,7 @@ describe Admin::ReportNotesController do
let(:params) { { report_note: { content: 'test content', report_id: report.id }, create_and_unresolve: nil } }
it 'creates a report note and unresolves report' do
expect{ subject }.to change{ ReportNote.count }.by(1)
expect { subject }.to change { ReportNote.count }.by(1)
expect(report.reload).not_to be_action_taken
expect(subject).to redirect_to admin_report_path(report)
end
@ -59,7 +58,7 @@ describe Admin::ReportNotesController do
let(:params) { { report_note: { content: 'test content', report_id: report.id } } }
it 'creates a report note and does not unresolve report' do
expect{ subject }.to change{ ReportNote.count }.by(1)
expect { subject }.to change { ReportNote.count }.by(1)
expect(report.reload).to be_action_taken
expect(subject).to redirect_to admin_report_path(report)
end
@ -84,7 +83,7 @@ describe Admin::ReportNotesController do
let!(:report_note) { Fabricate(:report_note) }
it 'deletes note' do
expect{ subject }.to change{ ReportNote.count }.by(-1)
expect { subject }.to change { ReportNote.count }.by(-1)
expect(subject).to redirect_to admin_report_path(report_note.report)
end
end

View File

@ -13,7 +13,7 @@ describe Admin::ReportedStatusesController do
describe 'POST #create' do
subject do
-> { post :create, params: { :report_id => report, action => '', :form_status_batch => { status_ids: status_ids } } }
-> { post :create, params: { :report_id => report, action => '', :form_status_batch => { status_ids: status_ids } } }
end
let(:action) { 'nsfw_on' }

View File

@ -24,7 +24,7 @@ describe Admin::StatusesController do
end
it 'returns http success with media' do
get :index, params: { account_id: account.id , media: true }
get :index, params: { account_id: account.id, media: true }
statuses = assigns(:statuses).to_a
expect(statuses.size).to eq 1

View File

@ -154,7 +154,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
before do
user.account.follow!(other_account)
post :mute, params: {id: other_account.id }
post :mute, params: { id: other_account.id }
end
it 'returns http success' do
@ -182,7 +182,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
before do
user.account.follow!(other_account)
post :mute, params: {id: other_account.id, notifications: false }
post :mute, params: { id: other_account.id, notifications: false }
end
it 'returns http success' do

View File

@ -25,7 +25,6 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control
expect(response.headers['Link'].links.size).to eq(2)
end
end
end
context 'without an oauth token' do

View File

@ -31,7 +31,7 @@ describe Api::V1::StreamingController do
describe 'GET #index' do
it 'redirects to streaming host' do
get :index, params: {access_token: 'deadbeef', stream: 'public'}
get :index, params: { access_token: 'deadbeef', stream: 'public' }
expect(response).to have_http_status(301)
request_uri = URI.parse(request.url)
redirect_to_uri = URI.parse(response.location)
@ -42,5 +42,4 @@ describe Api::V1::StreamingController do
end
end
end
end

View File

@ -5,7 +5,7 @@ require 'rails_helper'
describe Api::V1::Timelines::HomeController do
render_views
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice'), current_sign_in_at: 1.day.ago) }
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice'), current_sign_in_at: 1.day.ago) }
before do
allow(controller).to receive(:doorkeeper_token) { token }

View File

@ -5,7 +5,7 @@ require 'rails_helper'
describe Api::V1::Timelines::PublicController do
render_views
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
before do
allow(controller).to receive(:doorkeeper_token) { token }

View File

@ -14,7 +14,7 @@ describe Api::Web::EmbedsController do
context 'when successfully finds status' do
let(:status) { Fabricate(:status) }
let(:url) { "http://#{ Rails.configuration.x.web_domain }/@#{status.account.username}/#{status.id}" }
let(:url) { "http://#{Rails.configuration.x.web_domain}/@#{status.account.username}/#{status.id}" }
it 'returns a right response' do
expect(response).to have_http_status :ok

View File

@ -201,7 +201,7 @@ describe ApplicationController, type: :controller do
describe 'raise_not_found' do
it 'raises error' do
controller.params[:unmatched_route] = 'unmatched'
expect{ controller.raise_not_found }.to raise_error(ActionController::RoutingError, 'No route matches unmatched')
expect { controller.raise_not_found }.to raise_error(ActionController::RoutingError, 'No route matches unmatched')
end
end

View File

@ -67,7 +67,7 @@ describe Auth::ConfirmationsController, type: :controller do
end
describe 'PATCH #finish_signup' do
subject { patch :finish_signup, params: { user: { email: email }} }
subject { patch :finish_signup, params: { user: { email: email } } }
let(:user) { Fabricate(:user) }
before do

View File

@ -8,6 +8,7 @@ describe ApplicationController, type: :controller do
def index
send_export_file
end
def export_data
@export.account.username
end

View File

@ -43,7 +43,7 @@ describe InvitesController do
let(:user) { Fabricate(:user, moderator: false, admin: true) }
it 'succeeds to create a invite' do
expect{ subject }.to change { Invite.count }.by(1)
expect { subject }.to change { Invite.count }.by(1)
expect(subject).to redirect_to invites_path
expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10)
end

View File

@ -14,11 +14,11 @@ describe RemoteUnfollowsController do
before do
sign_in current_user
current_account.follow!(remote_account)
stub_request(:post, 'http://example.com/inbox'){ { status: 200 } }
stub_request(:post, 'http://example.com/inbox') { { status: 200 } }
end
context 'when successfully unfollow remote account' do
let(:acct) {"acct:#{ remote_account.username }@#{ remote_account.domain }"}
let(:acct) { "acct:#{remote_account.username}@#{remote_account.domain}" }
it do
is_expected.to render_template :success
@ -27,7 +27,7 @@ describe RemoteUnfollowsController do
end
context 'when fails to unfollow remote account' do
let(:acct) {"acct:#{ remote_account.username + '_test' }@#{ remote_account.domain }"}
let(:acct) { "acct:#{remote_account.username + '_test'}@#{remote_account.domain}" }
it do
is_expected.to render_template :error

View File

@ -21,7 +21,6 @@ describe Settings::ApplicationsController do
end
end
describe 'GET #show' do
it 'returns http success' do
get :show, params: { id: app.id }
@ -48,13 +47,13 @@ describe Settings::ApplicationsController do
context 'success (passed scopes as a String)' do
def call_create
post :create, params: {
doorkeeper_application: {
name: 'My New App',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
website: 'http://google.com',
scopes: 'read write follow'
}
}
doorkeeper_application: {
name: 'My New App',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
website: 'http://google.com',
scopes: 'read write follow'
}
}
response
end
@ -70,13 +69,13 @@ describe Settings::ApplicationsController do
context 'success (passed scopes as an Array)' do
def call_create
post :create, params: {
doorkeeper_application: {
name: 'My New App',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
website: 'http://google.com',
scopes: [ 'read', 'write', 'follow' ]
}
}
doorkeeper_application: {
name: 'My New App',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
website: 'http://google.com',
scopes: [ 'read', 'write', 'follow' ]
}
}
response
end
@ -92,13 +91,13 @@ describe Settings::ApplicationsController do
context 'failure' do
before do
post :create, params: {
doorkeeper_application: {
name: '',
redirect_uri: '',
website: '',
scopes: []
}
}
doorkeeper_application: {
name: '',
redirect_uri: '',
website: '',
scopes: []
}
}
end
it 'returns http success' do
@ -121,9 +120,9 @@ describe Settings::ApplicationsController do
def call_update
patch :update, params: {
id: app.id,
doorkeeper_application: opts
}
id: app.id,
doorkeeper_application: opts
}
response
end
@ -140,14 +139,14 @@ describe Settings::ApplicationsController do
context 'failure' do
before do
patch :update, params: {
id: app.id,
doorkeeper_application: {
name: '',
redirect_uri: '',
website: '',
scopes: []
}
}
id: app.id,
doorkeeper_application: {
name: '',
redirect_uri: '',
website: '',
scopes: []
}
}
end
it 'returns http success' do

View File

@ -10,7 +10,6 @@ describe Settings::MigrationsController do
end
describe 'GET #show' do
context 'when user is not sign in' do
subject { get :show }
@ -45,7 +44,6 @@ describe Settings::MigrationsController do
end
describe 'PUT #update' do
context 'when user is not sign in' do
subject { put :update }

View File

@ -50,7 +50,7 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do
describe 'when form_two_factor_confirmation parameter is not provided' do
it 'raises ActionController::ParameterMissing' do
expect { post :create, params: { } }.to raise_error(ActionController::ParameterMissing)
expect { post :create, params: {} }.to raise_error(ActionController::ParameterMissing)
end
end