Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9a033f2

Browse files
committedJul 28, 2021
Fix some style issues
1 parent 64aa93d commit 9a033f2

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed
 

‎spec/rails_app/config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RailsApp::Application.routes.draw do
2-
root :to => "home#index"
2+
root to: "home#index"
33

44
resources :posts do
55
resources :comments

‎spec/support/dummy_view.rb

+23-7
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,45 @@
33
class DummyView < ActionView::Base
44
module FakeRequest
55
class Request
6-
attr_accessor :path, :fullpath, :protocol, :host_with_port, :_request_method
6+
attr_accessor :path,
7+
:fullpath,
8+
:protocol,
9+
:host_with_port,
10+
:_request_method
711
def get?
8-
_request_method == nil ? true : _request_method == "GET"
12+
return true if _request_method.nil?
13+
14+
_request_method == "GET"
915
end
1016

1117
def post?
12-
_request_method == nil ? false : _request_method == "POST"
18+
return false if _request_method.nil?
19+
20+
_request_method == "POST"
1321
end
1422

1523
def put?
16-
_request_method == nil ? false : _request_method == "PUT"
24+
return false if _request_method.nil?
25+
26+
_request_method == "PUT"
1727
end
1828

1929
def patch?
20-
_request_method == nil ? false : _request_method == "PATCH"
30+
return false if _request_method.nil?
31+
32+
_request_method == "PATCH"
2133
end
2234

2335
def delete?
24-
_request_method == nil ? false : _request_method == "DELETE"
36+
return false if _request_method.nil?
37+
38+
_request_method == "DELETE"
2539
end
2640

2741
def head?
28-
_request_method == nil ? false : _request_method == "HEAD"
42+
return false if _request_method.nil?
43+
44+
_request_method == "HEAD"
2945
end
3046
end
3147
def request

‎spec/unit/view_extensions/breadcrumb_trail_spec.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,12 @@
283283

284284
it "match current path with :http_verbs" do
285285
view = DummyView.new
286-
view.breadcrumb("posts", "/posts", http_verbs: [:get, :post])
286+
view.breadcrumb("posts", "/posts", http_verbs: %i[get post])
287287
view.set_path("/posts")
288288
view.set_request_method(:post)
289289

290-
expect(view.breadcrumb_trail.map(&:to_a)).to eq([["posts", "/posts", true]])
290+
trail = view.breadcrumb_trail.map(&:to_a)
291+
expect(trail).to eq([["posts", "/posts", true]])
291292
end
292293

293294
it "fail to match current path with :http_verbs" do
@@ -296,7 +297,8 @@
296297
view.set_path("/posts")
297298
view.set_request_method(:post)
298299

299-
expect(view.breadcrumb_trail.map(&:to_a)).to eq([["posts", "/posts", false]])
300+
trail = view.breadcrumb_trail.map(&:to_a)
301+
expect(trail).to eq([["posts", "/posts", false]])
300302
end
301303

302304
it "match current path with :http_verbs => :all" do
@@ -305,6 +307,7 @@
305307
view.set_path("/posts")
306308
view.set_request_method(:delete)
307309

308-
expect(view.breadcrumb_trail.map(&:to_a)).to eq([["posts", "/posts", true]])
310+
trail = view.breadcrumb_trail.map(&:to_a)
311+
expect(trail).to eq([["posts", "/posts", true]])
309312
end
310313
end

0 commit comments

Comments
 (0)
Please sign in to comment.