Skip to content

Commit

Permalink
Fixed remaining tests, normalize describe calls, include ActiveJob::T…
Browse files Browse the repository at this point in the history
…estHelper everywhere
  • Loading branch information
Dantemss committed Oct 16, 2024
1 parent 3c07dcf commit d0bf854
Show file tree
Hide file tree
Showing 98 changed files with 123 additions and 111 deletions.
2 changes: 1 addition & 1 deletion spec/access_policies/contact_info_access_policy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe ContactInfoAccessPolicy do
describe ContactInfoAccessPolicy do

let!(:contact_info) { FactoryBot.create :email_address }
let!(:anon) { AnonymousUser.instance }
Expand Down
2 changes: 1 addition & 1 deletion spec/access_policies/external_id_access_policy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe ExternalIdAccessPolicy do
describe ExternalIdAccessPolicy do
let!(:anon) { AnonymousUser.instance }
let!(:temp) { FactoryBot.create :temp_user }
let!(:user) { FactoryBot.create :user }
Expand Down
2 changes: 1 addition & 1 deletion spec/access_policies/identity_access_policy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe IdentityAccessPolicy do
describe IdentityAccessPolicy do

let!(:identity) { FactoryBot.create :identity }
let!(:anon) { AnonymousUser.instance }
Expand Down
2 changes: 1 addition & 1 deletion spec/access_policies/user_access_policy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe UserAccessPolicy do
describe UserAccessPolicy do

let!(:anon) { AnonymousUser.instance }
let!(:temp) { FactoryBot.create :temp_user }
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/contact_infos_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Admin::ContactInfosController, type: :controller do
describe Admin::ContactInfosController, type: :controller do
let!(:user) { FactoryBot.create :user_with_emails }
let(:admin) { FactoryBot.create :user, :admin, :terms_agreed }
let(:email) { user.email_addresses.first }
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/external_ids_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Admin::ExternalIdsController, type: :controller do
describe Admin::ExternalIdsController, type: :controller do
let!(:external_id) { FactoryBot.create :external_id }
let(:admin) { FactoryBot.create :user, :admin, :terms_agreed }

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/pre_auth_states_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Admin::PreAuthStatesController, type: :controller do
describe Admin::PreAuthStatesController, type: :controller do
let(:admin) { FactoryBot.create :user, :admin, :terms_agreed }

before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/reports_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Admin::ReportsController, type: :controller do
describe Admin::ReportsController, type: :controller do
let(:admin) { FactoryBot.create :user, :admin, :terms_agreed }

before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/users_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Admin::UsersController, type: :controller do
describe Admin::UsersController, type: :controller do
let!(:user) { FactoryBot.create :user }
let!(:identity) { FactoryBot.create :identity, user: user }
let(:admin) { FactoryBot.create :user, :admin, :terms_agreed }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Api::V1::ApplicationGroupsController, type: :controller, api: true, version: :v1 do
describe Api::V1::ApplicationGroupsController, type: :controller, api: true, version: :v1 do

let!(:untrusted_application) { FactoryBot.create :doorkeeper_application }
let!(:trusted_application) { FactoryBot.create :doorkeeper_application, :trusted }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Api::V1::ApplicationUsersController, type: :controller, api: true, version: :v1 do
describe Api::V1::ApplicationUsersController, type: :controller, api: true, version: :v1 do

let!(:untrusted_application) { FactoryBot.create :doorkeeper_application }
let!(:trusted_application) { FactoryBot.create :doorkeeper_application, can_access_private_user_data: true }
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/api/v1/contact_infos_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Api::V1::ContactInfosController, type: :controller, api: true, version: :v1 do
describe Api::V1::ContactInfosController, type: :controller, api: true, version: :v1 do

let!(:untrusted_application) { FactoryBot.create :doorkeeper_application }

Expand Down
2 changes: 0 additions & 2 deletions spec/controllers/api/v1/messages_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require 'rails_helper'

describe Api::V1::MessagesController, type: :controller, api: true, version: :v1 do
include ActiveJob::TestHelper

let!(:untrusted_application) {
FactoryBot.create :doorkeeper_application,
email_from_address: '[email protected]'
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/api/v1/users_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Api::V1::UsersController, type: :controller, api: true, version: :v1 do
describe Api::V1::UsersController, type: :controller, api: true, version: :v1 do
let!(:untrusted_application) { FactoryBot.create :doorkeeper_application }
let!(:trusted_application) { FactoryBot.create :doorkeeper_application, :trusted }

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe ApplicationController, type: :controller do
describe ApplicationController, type: :controller do

let!(:user) { FactoryBot.create :user, :terms_agreed }
let!(:app_token) { FactoryBot.create :doorkeeper_access_token, resource_owner_id: nil }
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/contact_infos_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe ContactInfosController, type: :controller do
describe ContactInfosController, type: :controller do

let!(:user) { FactoryBot.create :user, :terms_agreed }
let!(:another_user) { FactoryBot.create :user, :terms_agreed }
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/controllers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe 'Controllers affected by initializers/controllers.rb', type: :controller do
describe 'Controllers affected by initializers/controllers.rb', type: :controller do

context '#save_redirect' do

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Doorkeeper::AuthorizationsController, type: :controller do
describe Doorkeeper::AuthorizationsController, type: :controller do
before { controller.sign_in! user }

let(:app) { FactoryBot.create :doorkeeper_application }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe ExternalUserCredentialsController, type: :controller do
describe ExternalUserCredentialsController, type: :controller do
render_views

let(:user) { FactoryBot.create :user, :terms_agreed, state: User::EXTERNAL }
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/faculty_access_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe FacultyAccessController, type: :controller do
describe FacultyAccessController, type: :controller do
let(:user) do
create_user('user')
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

module Newflow
RSpec.describe EducatorSignupController, type: :controller do
describe EducatorSignupController, type: :controller do
before { turn_on_educator_feature_flag }

describe 'GET #educator_signup_form' do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/newflow/login_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

module Newflow
RSpec.describe LoginController, type: :controller do
describe LoginController, type: :controller do
before { turn_on_educator_feature_flag }

describe 'GET #login_form' do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

module Newflow
RSpec.describe PasswordManagementController, type: :controller do
describe PasswordManagementController, type: :controller do
describe 'GET #forgot_password_form' do
it 'has a 200 status code' do
get('forgot_password_form')
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/newflow/signup_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

module Newflow
RSpec.describe SignupController, type: :controller do
describe SignupController, type: :controller do
describe 'GET #welcome' do
it 'renders welcome form/page' do
get(:welcome)
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/newflow/social_auth_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

module Newflow
RSpec.describe SocialAuthController, type: :controller do
describe SocialAuthController, type: :controller do
describe 'GET #oauth_callback' do
let(:info) do
{ email: '[email protected]', name: Faker::Name.name }
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/newflow/student_signup_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

module Newflow
RSpec.describe StudentSignupController, type: :controller do
describe StudentSignupController, type: :controller do
describe 'GET #student_signup_form' do
it 'renders student signup_form' do
get(:student_signup_form)
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/other_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe OtherController, type: :controller do
describe OtherController, type: :controller do
describe 'GET #profile_newflow' do
context 'when logged in' do
before do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/terms_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'
require 'byebug'

RSpec.describe TermsController, type: :controller do
describe TermsController, type: :controller do
let(:contract) { FactoryBot.create :fine_print_contract, :published }
let!(:user_1) { create_user 'user1' }
let!(:user_2) { create_user 'user2' }
Expand Down
2 changes: 1 addition & 1 deletion spec/delayed/worker_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Delayed::Worker, type: :lib do
describe Delayed::Worker, type: :lib do
let(:job) { ::ActiveJob::Base.new }
let(:delayed_job) { ::Delayed::Job.create!(payload_object: job) }
subject(:delayed_worker) { described_class.new }
Expand Down
6 changes: 6 additions & 0 deletions spec/features/newflow/educator_signup_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ module Newflow
submit_signup_form
screenshot!

perform_enqueued_jobs

# Step 2
# sends an email address confirmation email
expect(page.current_path).to eq(educator_email_verification_form_path)
Expand Down Expand Up @@ -84,6 +86,8 @@ module Newflow
submit_signup_form
screenshot!

perform_enqueued_jobs

# Step 2
# sends an email address confirmation email
expect(page.current_path).to eq(educator_email_verification_form_path)
Expand Down Expand Up @@ -198,6 +202,8 @@ module Newflow
submit_signup_form
screenshot!

perform_enqueued_jobs

# Step 2
# sends an email address confirmation email
expect(page.current_path).to eq(educator_email_verification_form_path)
Expand Down
6 changes: 6 additions & 0 deletions spec/features/newflow/reset_password_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
)
)

perform_enqueued_jobs

open_email('[email protected]')
password_reset_link = get_path_from_absolute_link(current_email, 'a')
visit password_reset_link
Expand Down Expand Up @@ -63,6 +65,7 @@
t(:'login_signup_form.password_reset_email_sent_description', email: '[email protected]')
)
)
perform_enqueued_jobs
open_email('[email protected]')
expect(current_email).to have_content('reset')
end
Expand All @@ -85,6 +88,7 @@
# expect(page).to have_content(I18n.t(:"login_signup_form.password_reset_email_sent"))
# screenshot!
#
# perform_enqueued_jobs
# open_email('[email protected]')
# change_password_link_1 = get_path_from_absolute_link(current_email, 'a')
# clear_emails
Expand All @@ -99,6 +103,7 @@
# click_on(I18n.t(:"login_signup_form.reset_my_password_button"))
# expect(page).to have_content(I18n.t(:"login_signup_form.password_reset_email_sent"))
#
# perform_enqueued_jobs
# open_email('[email protected]')
# change_password_link_2 = get_path_from_absolute_link(current_email, 'a')
# clear_emails
Expand All @@ -116,6 +121,7 @@
# click_on(I18n.t(:"login_signup_form.reset_my_password_button"))
# expect(page).to have_content(I18n.t(:"login_signup_form.password_reset_email_sent"))
#
# perform_enqueued_jobs
# open_email('[email protected]')
# change_password_link_3 = get_path_from_absolute_link(current_email, 'a')
# clear_emails
Expand Down
2 changes: 2 additions & 0 deletions spec/features/newflow/student_login_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ module Newflow
expect(page).to have_content(I18n.t(:"login_signup_form.password_reset_email_sent"))
screenshot!

perform_enqueued_jobs

open_email('[email protected]')
capture_email!
change_password_link = get_path_from_absolute_link(current_email, 'a')
Expand Down
8 changes: 8 additions & 0 deletions spec/features/newflow/student_signup_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ module Newflow
submit_signup_form
screenshot!

perform_enqueued_jobs

# sends an email address confirmation email
expect(page.current_path).to eq student_email_verification_form_path
open_email email
Expand Down Expand Up @@ -112,6 +114,8 @@ module Newflow
submit_signup_form
screenshot!

perform_enqueued_jobs

# sends an email address confirmation email
expect(page.current_path).to eq student_email_verification_form_path
open_email email
Expand Down Expand Up @@ -170,6 +174,8 @@ module Newflow
submit_signup_form
screenshot!

perform_enqueued_jobs

# an email gets sent
open_email email
# capture_email!(address: email)
Expand All @@ -192,6 +198,8 @@ module Newflow
screenshot!
expect(page).to have_text(t(:"login_signup_form.check_your_updated_email"))

perform_enqueued_jobs

# a different pin is sent in the edited email
open_email new_email
capture_email!(address: new_email)
Expand Down
6 changes: 6 additions & 0 deletions spec/features/newflow/user_cant_sign_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
# expect(page.first('input')["placeholder"]).to eq t(:"legacy.sessions.start.username_placeholder")
# expect(page.first('input').text).to be_blank

# perform_enqueued_jobs

# open_email(email_address)
# expect(current_email).to have_content('used on more than one')
# expect(current_email).to have_content('user1 and user2')
Expand Down Expand Up @@ -125,6 +127,8 @@
# expect(page).to have_content(t(:"login_signup_form.password_reset_email_sent"))
# screenshot!
#
# perform_enqueued_jobs
#
# open_email('[email protected]')
# capture_email!
# change_password_link = get_path_from_absolute_link(current_email, 'a')
Expand Down Expand Up @@ -160,6 +164,8 @@
expect(page).to have_content(t(:"legacy.identities.send_add.we_sent_email", emails: '[email protected]'))
screenshot!

perform_enqueued_jobs

open_email('[email protected]')
expect(current_email).to have_content("Click here to add")
capture_email!
Expand Down
2 changes: 0 additions & 2 deletions spec/features/newflow/user_claims_account_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require 'rails_helper'

feature 'User claims an unclaimed account' do
include ActiveJob::TestHelper

before do
turn_on_student_feature_flag
end
Expand Down
Loading

0 comments on commit d0bf854

Please sign in to comment.