Skip to content

Commit

Permalink
test: rubocop, try refactor logout
Browse files Browse the repository at this point in the history
  • Loading branch information
adi-herwana-nus committed Sep 30, 2024
1 parent 239ea98 commit 48ee877
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion spec/factories/courses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FactoryBot.define do
factory :course do
transient do
prefix { "Course " }
prefix { 'Course ' }
end
sequence(:title) do |n|
timestamp = Time.zone.now.to_i.to_s
Expand Down
10 changes: 5 additions & 5 deletions spec/factories/instance_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
role { :normal }

after(:build) do |instance_user, evaluator|
if evaluator.user_name
instance_user.user ||= build(:user, name: evaluator.user_name, instance_users: [instance_user])
else
instance_user.user ||= build(:user, instance_users: [instance_user])
end
instance_user.user ||= if evaluator.user_name
build(:user, name: evaluator.user_name, instance_users: [instance_user])
else
instance_user.user ||= build(:user, instance_users: [instance_user])
end
end

trait :instructor do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let(:instance_admin) { create(:instance_user, role: :administrator).user }
let!(:prefix) { "admtest-#{rand(36**12).to_s(36)}-usr-" }
let!(:instance_users) do
(1..2).collect do |i|
(1..2).map do |i|
create(:instance_user, user_name: "#{prefix}#{i}")
end
end
Expand Down
7 changes: 3 additions & 4 deletions spec/support/authentication_performers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ def login_as(user, _ = {})
fill_in 'Password', with: password_for(user)
click_button 'Sign In'

# We expect all pages should have a user menu button.
# We expect all authenticated pages should have a user menu button.
expect(page).to have_css('div[data-testid="user-menu-button"]')
end

def logout(*_)
find('div[data-testid="user-menu-button"]').click
find('li', text: 'Sign out').click
click_button 'Logout'

wait_for_page
click_button('Logout', wait: 10)
expect(page).to_not have_css('div[data-testid="user-menu-button"]')
end

private
Expand Down

0 comments on commit 48ee877

Please sign in to comment.