Fix RSpec/InstanceVariable
cop (#27766)
This commit is contained in:
parent
4329616c53
commit
69d00e2721
11 changed files with 97 additions and 124 deletions
|
@ -26,7 +26,6 @@ describe Api::V1::StreamingController do
|
|||
context 'with streaming api on different host' do
|
||||
before do
|
||||
Rails.configuration.x.streaming_api_base_url = "wss://streaming-#{Rails.configuration.x.web_domain}"
|
||||
@streaming_host = URI.parse(Rails.configuration.x.streaming_api_base_url).host
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
|
@ -38,7 +37,13 @@ describe Api::V1::StreamingController do
|
|||
[:scheme, :path, :query, :fragment].each do |part|
|
||||
expect(redirect_to_uri.send(part)).to eq(request_uri.send(part)), "redirect target #{part}"
|
||||
end
|
||||
expect(redirect_to_uri.host).to eq(@streaming_host), 'redirect target host'
|
||||
expect(redirect_to_uri.host).to eq(streaming_host), 'redirect target host'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def streaming_host
|
||||
URI.parse(Rails.configuration.x.streaming_api_base_url).host
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,12 +18,14 @@ describe Auth::PasswordsController do
|
|||
|
||||
before do
|
||||
request.env['devise.mapping'] = Devise.mappings[:user]
|
||||
@token = user.send_reset_password_instructions
|
||||
end
|
||||
|
||||
context 'with valid reset_password_token' do
|
||||
it 'returns http success' do
|
||||
get :edit, params: { reset_password_token: @token }
|
||||
token = user.send_reset_password_instructions
|
||||
|
||||
get :edit, params: { reset_password_token: token }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
@ -38,9 +40,9 @@ describe Auth::PasswordsController do
|
|||
|
||||
describe 'POST #update' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:password) { 'reset0password' }
|
||||
|
||||
before do
|
||||
@password = 'reset0password'
|
||||
request.env['devise.mapping'] = Devise.mappings[:user]
|
||||
end
|
||||
|
||||
|
@ -50,9 +52,9 @@ describe Auth::PasswordsController do
|
|||
let!(:web_push_subscription) { Fabricate(:web_push_subscription, access_token: access_token) }
|
||||
|
||||
before do
|
||||
@token = user.send_reset_password_instructions
|
||||
token = user.send_reset_password_instructions
|
||||
|
||||
post :update, params: { user: { password: @password, password_confirmation: @password, reset_password_token: @token } }
|
||||
post :update, params: { user: { password: password, password_confirmation: password, reset_password_token: token } }
|
||||
end
|
||||
|
||||
it 'redirect to sign in' do
|
||||
|
@ -63,7 +65,7 @@ describe Auth::PasswordsController do
|
|||
this_user = User.find(user.id)
|
||||
|
||||
expect(this_user).to_not be_nil
|
||||
expect(this_user.valid_password?(@password)).to be true
|
||||
expect(this_user.valid_password?(password)).to be true
|
||||
end
|
||||
|
||||
it 'deactivates all sessions' do
|
||||
|
@ -81,7 +83,7 @@ describe Auth::PasswordsController do
|
|||
|
||||
context 'with invalid reset_password_token' do
|
||||
before do
|
||||
post :update, params: { user: { password: @password, password_confirmation: @password, reset_password_token: 'some_invalid_value' } }
|
||||
post :update, params: { user: { password: password, password_confirmation: password, reset_password_token: 'some_invalid_value' } }
|
||||
end
|
||||
|
||||
it 'renders reset password' do
|
||||
|
|
|
@ -11,7 +11,7 @@ describe ExportControllerConcern do
|
|||
end
|
||||
|
||||
def export_data
|
||||
@export.account.username
|
||||
'body data value'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -24,7 +24,7 @@ describe ExportControllerConcern do
|
|||
expect(response).to have_http_status(200)
|
||||
expect(response.media_type).to eq 'text/csv'
|
||||
expect(response.headers['Content-Disposition']).to start_with 'attachment; filename="anonymous.csv"'
|
||||
expect(response.body).to eq user.account.username
|
||||
expect(response.body).to eq 'body data value'
|
||||
end
|
||||
|
||||
it 'returns unauthorized when not signed in' do
|
||||
|
|
|
@ -5,9 +5,10 @@ require 'rails_helper'
|
|||
RSpec.describe StatusesCleanupController do
|
||||
render_views
|
||||
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
@user = Fabricate(:user)
|
||||
sign_in @user, scope: :user
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
|
@ -30,9 +31,9 @@ RSpec.describe StatusesCleanupController do
|
|||
end
|
||||
|
||||
it 'updates the account status cleanup policy' do
|
||||
expect(@user.account.statuses_cleanup_policy.enabled).to be true
|
||||
expect(@user.account.statuses_cleanup_policy.keep_direct).to be false
|
||||
expect(@user.account.statuses_cleanup_policy.keep_polls).to be true
|
||||
expect(user.account.statuses_cleanup_policy.enabled).to be true
|
||||
expect(user.account.statuses_cleanup_policy.keep_direct).to be false
|
||||
expect(user.account.statuses_cleanup_policy.keep_polls).to be true
|
||||
end
|
||||
|
||||
it 'redirects' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue