Skip to content

Commit

Permalink
Merge pull request #106 from ackama/add-sort
Browse files Browse the repository at this point in the history
chore: fix linting errors
  • Loading branch information
eoinkelly committed Jul 10, 2020
2 parents 5272eb7 + e22a8f9 commit 6ce1bea
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
6 changes: 3 additions & 3 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f }

# Checks for pending migrations and applies them before tests are run.
# If you are not using ActiveRecord, you can remove these lines.
Expand All @@ -38,10 +38,10 @@
options = Selenium::WebDriver::Chrome::Options.new

options.add_argument("--window-size=1920,1080")


# Add other Chrome arguments here

# Docker compatibility
options.add_argument("--headless")
options.add_argument("--no-sandbox")
Expand Down
6 changes: 3 additions & 3 deletions variants/devise/spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

it "is valid when created with valid attributes" do
valid_password = "aaaabbbbccccdddd"
user = User.new(email: "picard@uss1701d.com",
password: valid_password,
password_confirmation: valid_password)
user = described_class.new(email: "picard@uss1701d.com",
password: valid_password,
password_confirmation: valid_password)
expect(user).to be_valid
end
end
8 changes: 3 additions & 5 deletions variants/devise/spec/requests/session_cookie_expiry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
get edit_user_registration_path

# ... then it works.
expect(response).to have_http_status(200)
expect(response).to have_http_status(:ok)
expect(response.body).to match(/Edit User/)

# Save the signed-in user's session cookie
Expand All @@ -26,7 +26,7 @@
get edit_user_registration_path

# ... then we are redirected to the sign-in page
expect(response).to have_http_status(302)
expect(response).to have_http_status(:found)
expect(response.headers["Location"]).to eq(new_user_session_url)

# When we try to view the private page, this time passing the old session
Expand All @@ -35,9 +35,7 @@

# ... then we are still redirected to the sign-in page (this demonstrates
# that session cookies are properly invalidated when a user signs out)
expect(response).to have_http_status(302)
expect(response).to have_http_status(:found)
expect(response.headers["Location"]).to eq(new_user_session_url)
end
end


Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
RSpec.describe "Users can reset passwords", type: :system do
describe "accessibility" do
before { visit new_user_password_path }

it_behaves_like "an accessible page"
end

Expand All @@ -14,7 +15,7 @@
before { visit new_user_session_path }

context "with existing users" do
before(:each) do
before do
FactoryBot.create(:user, email: email_of_existing_user, password: valid_password)
end

Expand All @@ -24,7 +25,7 @@
click_button "Send me reset password instructions"

# we expect to be redirected to the sign-in page ...
expect(page.current_path).to eq(new_user_session_path)
expect(page).to have_current_path(new_user_session_path, ignore_query: true)
# ...with a helpful flash message
expect(page).to have_text("If your email address exists in our database, you will receive a password recovery")

Expand All @@ -44,7 +45,7 @@
click_button "Send me reset password instructions"

# we expect to be redirected to the user sign-in page ...
expect(page.current_path).to eq(new_user_session_path)
expect(page).to have_current_path(new_user_session_path, ignore_query: true)
# ... with a helpful flash message
expect(page).to have_text("If your email address exists in our database, you will receive a password recovery")
end
Expand Down
27 changes: 14 additions & 13 deletions variants/devise/spec/system/user_sign_in_feature_spec.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
require "rails_helper"

RSpec.describe "User sign-in", type: :system do
describe "accessibility" do
before { visit new_user_session_path }
it_behaves_like "an accessible page"
end

let(:email) { "miles.obrien@transporterrm3.enterprise.uss" }
let(:password) { "aaaabbbbccccdddd" }
let(:user) { FactoryBot.create(:user, email: email, password: password) }
let(:password) { "aaaabbbbccccdddd" }
let(:email) { "miles.obrien@transporterrm3.enterprise.uss" }

before(:each) do
before do
user # create the user
visit new_user_session_path
end

describe "accessibility" do
before { visit new_user_session_path }

it_behaves_like "an accessible page"
end

context "when a user has valid account details" do
it "can sign-in and sign-out successfully" do
# when we fill in the sign-in form
Expand All @@ -23,7 +24,7 @@
click_button "Log in"

# we expect to be redirected to the home page with a helpful flash message
expect(page.current_path).to eq(root_path)
expect(page).to have_current_path(root_path, ignore_query: true)
expect(page).to have_text("Signed in successfully")

# we expect there to be exactly one cookie set and that cookie has a name
Expand All @@ -37,7 +38,7 @@

# we expect to still be on the home page with a flash message
# telling us we have signed out.
expect(page.current_path).to eq(root_path)
expect(page).to have_current_path(root_path, ignore_query: true)
expect(page).to have_text("Signed out successfully")
end

Expand All @@ -50,14 +51,14 @@
click_button "Log in"

# we expect to be redirected to the home page with a helpful flash message
expect(page.current_path).to eq(root_path)
expect(page).to have_current_path(root_path, ignore_query: true)
expect(page).to have_text("Signed in successfully")

# we expect there to be exactly two cookies set and that one of them
# has the name "remember_user_token"
response_cookies = Capybara.current_session.driver.request.cookies
expect(response_cookies.keys.length).to eq(2)
expect(response_cookies["remember_user_token"]).to_not eq(nil)
expect(response_cookies["remember_user_token"]).not_to eq(nil)

# We expect the "remember me" cookie to have a 14 day expiry
remember_me_cookie_expiry_date = JSON
Expand Down Expand Up @@ -88,7 +89,7 @@

# we expect to still be on the sign-in page with a helpful flash message
# telling us something went wrong
expect(page.current_path).to eq(new_user_session_path)
expect(page).to have_current_path(new_user_session_path, ignore_query: true)
expect(page).to have_text("Invalid Email or password")
end
end
Expand Down
21 changes: 11 additions & 10 deletions variants/devise/spec/system/user_sign_up_feature_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
require "rails_helper"

RSpec.describe "User sign-up", type: :system do
let(:too_short_password) { "aabbcc" }
let(:valid_password) { "aaaabbbbccccdddd" }
let(:invalid_email) { "miles.obrien@" }
let(:valid_email) { "miles.obrien@transporterrm3.enterprise.uss" }

before { visit new_user_registration_path }

describe "accessibility" do
before { visit new_user_registration_path }

it_behaves_like "an accessible page"
end

let(:valid_email) { "miles.obrien@transporterrm3.enterprise.uss" }
let(:invalid_email) { "miles.obrien@" }
let(:valid_password) { "aaaabbbbccccdddd" }
let(:too_short_password) { "aabbcc" }

before { visit new_user_registration_path }

it "Users can sign-up" do
# when we sign up with valid credentials
fill_in "Email", with: valid_email
Expand All @@ -21,7 +22,7 @@
click_button "Sign up"

# we expect to be redirected to the home page ...
expect(page.current_path).to eq(root_path)
expect(page).to have_current_path(root_path, ignore_query: true)
# ... with a helpful flash message
expect(page).to have_text("You have signed up successfully")
# and to be already signed in
Expand All @@ -37,7 +38,7 @@
click_button "Sign up"

# we expect to now be on the user registration page ...
expect(page.current_path).to eq(user_registration_path)
expect(page).to have_current_path(user_registration_path, ignore_query: true)
# ... with a helpful flash message
expect(page).to have_text("Email is invalid")
end
Expand All @@ -57,7 +58,7 @@
click_button "Sign up"

# we expect to now be on the user registration page ...
expect(page.current_path).to eq(user_registration_path)
expect(page).to have_current_path(user_registration_path, ignore_query: true)
# ... with a helpful flash message
expect(page).to have_text("Password is too short (minimum is 16 characters)")
end
Expand Down

0 comments on commit 6ce1bea

Please sign in to comment.