Skip to content

Commit fe13cd1

Browse files
author
Template Bot
committed
Apply template update: Rubocop: require click_on in system tests
Source: mockdeep/Rails-Template#1393
1 parent 57af14d commit fe13cd1

File tree

6 files changed

+193
-0
lines changed

6 files changed

+193
-0
lines changed

.rubocop.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ AllCops:
1616
- 'db/schema.rb'
1717
- 'vendor/**/*'
1818

19+
<<<<<<< HEAD
1920
Capybara/ClickLinkOrButtonStyle: { EnforcedStyle: link_or_button }
2021
Layout/LineLength: { Max: 80, Exclude: [db/migrate/*.rb] }
2122
Layout/RedundantLineBreak: { InspectBlocks: true }
@@ -31,6 +32,35 @@ RSpec/MessageExpectation:
3132
RSpec/MessageSpies: { EnforcedStyle: receive }
3233
RSpec/MultipleMemoizedHelpers: { AllowSubject: false, Max: 0 }
3334
Style/ClassAndModuleChildren: { EnforcedStyle: compact }
35+
=======
36+
################################################################################
37+
#
38+
# Rules that depart from rubocop defaults
39+
#
40+
################################################################################
41+
42+
Style/ModuleFunction: { EnforcedStyle: extend_self }
43+
Layout/LineLength:
44+
Max: 80
45+
AutoCorrect: true
46+
Exclude: ['config/**/*']
47+
Layout/MultilineMethodCallIndentation: { EnforcedStyle: indented }
48+
Layout/MultilineOperationIndentation: { EnforcedStyle: indented }
49+
Metrics/BlockLength:
50+
AllowedMethods:
51+
- describe
52+
Exclude:
53+
- Guardfile
54+
- db/schema.rb
55+
- config/environments/development.rb
56+
Rails/FilePath: { EnforcedStyle: slashes }
57+
Metrics/MethodLength: { Exclude: [db/migrate/**/*.rb] }
58+
RSpec/MultipleExpectations:
59+
Exclude:
60+
- spec/system/**/*.rb
61+
RSpec/MessageExpectation: { EnforcedStyle: expect }
62+
Style/ArrayFirstLast: { Exclude: [Guardfile] }
63+
>>>>>>> bfb1757 (Rubocop: require click_on in system tests (#1393))
3464
Style/MethodCallWithArgsParentheses:
3565
AllowedMethods:
3666
- and
@@ -56,18 +86,25 @@ Style/Documentation: { Enabled: false }
5686
################################################################################
5787

5888
Bundler/GemComment: { Enabled: false }
89+
<<<<<<< HEAD
5990
Bundler/GemVersion: { Enabled: false }
91+
=======
92+
>>>>>>> bfb1757 (Rubocop: require click_on in system tests (#1393))
6093
Capybara/AmbiguousClick: { Enabled: false }
6194
Layout/SingleLineBlockChain: { Enabled: false }
6295
Lint/ConstantResolution: { Enabled: false }
6396
Rails/BulkChangeTable: { Enabled: false }
6497
Rails/RedundantPresenceValidationOnBelongsTo: { Enabled: false }
6598
RSpec/AlignLeftLetBrace: { Enabled: false }
6699
RSpec/AlignRightLetBrace: { Enabled: false }
100+
<<<<<<< HEAD
67101
Rails/HasManyOrHasOneDependent: { Enabled: false }
68102
RSpec/IndexedLet: { Enabled: false }
69103
RSpec/StubbedMock: { Enabled: false }
70104
Rails/SchemaComment: { Enabled: false }
105+
=======
106+
Style/CommentedKeyword: { Enabled: false }
107+
>>>>>>> bfb1757 (Rubocop: require click_on in system tests (#1393))
71108
Style/ConstantVisibility: { Enabled: false }
72109
Style/Copyright: { Enabled: false }
73110
Style/InlineComment: { Enabled: false }

.rubocop_todo.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ Capybara/NegationMatcherAfterVisit:
1212
- 'spec/system/account_setup_spec.rb'
1313
- 'spec/system/stories_index_spec.rb'
1414

15+
<<<<<<< HEAD
1516
# Offense count: 6
17+
=======
18+
# Offense count: 2
19+
>>>>>>> bfb1757 (Rubocop: require click_on in system tests (#1393))
1620
# This cop supports safe autocorrection (--autocorrect).
1721
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
1822
# SupportedHashRocketStyles: key, separator, table

app/views/layouts/application.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# frozen_string_literal: true
2+
3+
module Views
4+
module Layouts
5+
class Application < Components::Base
6+
include Phlex::Rails::Helpers::CSRFMetaTags
7+
include Phlex::Rails::Helpers::CSPMetaTag
8+
include Phlex::Rails::Helpers::StylesheetLinkTag
9+
include Phlex::Rails::Helpers::JavascriptIncludeTag
10+
include Phlex::Rails::Helpers::LinkTo
11+
include Phlex::Rails::Helpers::LinkToUnlessCurrent
12+
include Phlex::Rails::Helpers::Flash
13+
14+
def view_template
15+
doctype
16+
17+
html do
18+
head do
19+
title { "YourAppNameHere" }
20+
csrf_meta_tags
21+
csp_meta_tag
22+
23+
stylesheet_link_tag("application", media: "all")
24+
javascript_include_tag("application")
25+
end
26+
27+
action = "keydown@document->hotkeys#handleKeydown"
28+
body(data: { controller: "hotkeys", action: }) do
29+
if current_user.logged_in?
30+
plain(current_user.email)
31+
link_to("Account", account_path)
32+
button_to("Log Out", session_path, method: :delete)
33+
else
34+
link_to_unless_current("Log In", new_session_path)
35+
link_to_unless_current("Sign Up", new_account_path)
36+
end
37+
38+
div(class: "flashes") do
39+
flash.each do |type, message|
40+
div(class: "flash-#{type}") { message }
41+
end
42+
end
43+
44+
yield
45+
end
46+
end
47+
end
48+
end
49+
end
50+
end

spec/support/coverage.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
require "coveralls"
99
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
1010
end
11+
<<<<<<< HEAD
1112

1213
SimpleCov.start(:rails) do
1314
add_group("Commands", "app/commands")
@@ -18,3 +19,5 @@
1819
enable_coverage :branch
1920
end
2021
SimpleCov.minimum_coverage(line: 100, branch: 100)
22+
=======
23+
>>>>>>> bfb1757 (Rubocop: require click_on in system tests (#1393))

spec/system/account_spec.rb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe "user account" do
4+
def sign_up_with(
5+
email: "demo@lmkw.io",
6+
password: "secret",
7+
password_confirmation: password
8+
)
9+
visit("/")
10+
click_on("Sign Up")
11+
fill_in("Email", with: email)
12+
fill_in("Password", with: password)
13+
fill_in("Password confirmation", with: password_confirmation)
14+
click_on("Create Account")
15+
end
16+
17+
def update_account_with(email:)
18+
click_on("Account")
19+
fill_in("Email", with: email)
20+
21+
click_on("Update Account")
22+
end
23+
24+
def delete_account
25+
click_on("Account")
26+
27+
# accept_confirm("Are you sure? This cannot be undone.") do
28+
click_on("Delete Account")
29+
# end
30+
end
31+
32+
it "allows a user to sign up for an account" do
33+
sign_up_with(email: "demo@lmkw.io")
34+
35+
expect(page).to have_flash(:success, "Account created")
36+
expect(page).to have_text("demo@lmkw.io")
37+
end
38+
39+
it "allows a user to edit their email" do
40+
sign_up_with(email: "demo@lmkw.io")
41+
update_account_with(email: "demo2@lmkw.io")
42+
43+
expect(page).to have_text("demo2@lmkw.io")
44+
end
45+
46+
it "allows a user to delete their account" do
47+
sign_up_with(email: "demo@lmkw.io")
48+
49+
delete_account
50+
51+
expect(page).to have_flash(:success, "Account permanently deleted")
52+
expect(page).to have_no_text("demo@lmkw.io")
53+
end
54+
end

spec/system/sessions_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe "user sessions" do
4+
def user_params
5+
{
6+
email: "demo@lmkw.io",
7+
password: "secret",
8+
password_confirmation: "secret",
9+
}
10+
end
11+
12+
def sign_in_with(email:, password:)
13+
visit("/")
14+
15+
click_on("Log In")
16+
17+
expect(page).to have_text("Log in to YourAppNameHere")
18+
19+
fill_in("Email", with: email)
20+
fill_in("Password", with: password)
21+
22+
click_on("Log In")
23+
end
24+
25+
it "allows a user to log into their account" do
26+
user = User.create!(user_params)
27+
28+
sign_in_with(email: user.email, password: user.password)
29+
30+
expect(page).to have_text(user.email)
31+
expect(page).to have_link("Account")
32+
expect(page).to have_no_link("Log In")
33+
end
34+
35+
it "allows a user to log out" do
36+
user = User.create!(user_params)
37+
38+
sign_in_with(email: user.email, password: user.password)
39+
40+
click_on("Log Out")
41+
42+
expect(page).to have_link("Log In")
43+
expect(page).to have_no_text(user.email)
44+
end
45+
end

0 commit comments

Comments
 (0)