Skip to content

Commit

Permalink
Appease Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
bknoles committed Dec 8, 2024
1 parent 892b281 commit 1413358
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 13 deletions.
4 changes: 3 additions & 1 deletion lib/inertia_rails/defer_prop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

module InertiaRails
class DeferProp < IgnoreOnFirstLoadProp
DEFAULT_GROUP = "default"
DEFAULT_GROUP = 'default'

attr_reader :group

def initialize(group: nil, merge: nil, &block)
super(&block)

@group = group || DEFAULT_GROUP
@merge = merge
@block = block
Expand Down
2 changes: 1 addition & 1 deletion lib/inertia_rails/lazy_prop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def initialize(value = nil, &block)
raise ArgumentError, 'You must provide either a value or a block, not both' if value && block

InertiaRails.deprecator.warn(
"`lazy` is deprecated and will be removed in InertiaRails 4.0, use `optional` instead."
'`lazy` is deprecated and will be removed in InertiaRails 4.0, use `optional` instead.'
)

@value = value
Expand Down
2 changes: 2 additions & 0 deletions lib/inertia_rails/optional_prop.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module InertiaRails
class OptionalProp < IgnoreOnFirstLoadProp
end
Expand Down
4 changes: 1 addition & 3 deletions lib/inertia_rails/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ def deferred_props_keys

def merge_props_keys
@props.each_with_object([]) do |(key, prop), result|
if prop.try(:merge?) && reset_keys.exclude?(key)
result << key
end
result << key if prop.try(:merge?) && reset_keys.exclude?(key)
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class InertiaEncryptHistoryController < ApplicationController
inertia_config(
encrypt_history: -> { action_name != "default_config" }
encrypt_history: -> { action_name != 'default_config' }
)

def default_config
Expand All @@ -20,6 +22,6 @@ def clear_history
end

def clear_history_after_redirect
redirect_to :empty_test, inertia: {clear_history: true}
redirect_to :empty_test, inertia: { clear_history: true }
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def merge_props
render inertia: 'TestComponent', props: {
merge: InertiaRails.merge { 'merge prop' },
regular: 'regular prop',
deferred_merge: InertiaRails.defer(merge: true) { 'deferred and merge prop'},
deferred_merge: InertiaRails.defer(merge: true) { 'deferred and merge prop' },
deferred: InertiaRails.defer { 'deferred' },
}
end
Expand Down
5 changes: 3 additions & 2 deletions spec/inertia/encrypt_history_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

RSpec.describe 'Inertia encrypt history', type: :request do
let(:headers) { {'X-Inertia' => true} }
let(:headers) { { 'X-Inertia' => true } }

context 'with default config' do
it 'returns encryptHistory false' do
Expand All @@ -20,7 +22,6 @@
end

context 'with override config' do

it 'returns encryptHistory false' do
get encrypt_history_override_config_path, headers: headers

Expand Down
4 changes: 2 additions & 2 deletions spec/inertia/lazy_prop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
end
end

it "is deprecated" do
expect(deprecator).to receive(:warn).with("`lazy` is deprecated and will be removed in InertiaRails 4.0, use `optional` instead.")
it 'is deprecated' do
expect(deprecator).to receive(:warn).with('`lazy` is deprecated and will be removed in InertiaRails 4.0, use `optional` instead.')

described_class.new('value')
end
Expand Down
2 changes: 1 addition & 1 deletion spec/inertia/rendering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
'X-Inertia' => true,
'X-Inertia-Partial-Data' => 'deferred_merge',
'X-Inertia-Partial-Component' => 'TestComponent',
'X-Inertia-Reset' => 'deferred_merge'
'X-Inertia-Reset' => 'deferred_merge',
}}

it 'returns listed and merge props' do
Expand Down
2 changes: 2 additions & 0 deletions spec/inertia/ssr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
it 'renders inertia without ssr as a fallback' do
get props_path

# rubocop:disable Layout/LineLength
expect(response.body).to include '<div id="app" data-page="{&quot;component&quot;:&quot;TestComponent&quot;,&quot;props&quot;:{&quot;name&quot;:&quot;Brandon&quot;,&quot;sport&quot;:&quot;hockey&quot;},&quot;url&quot;:&quot;/props&quot;,&quot;version&quot;:&quot;1.0&quot;,&quot;encryptHistory&quot;:false,&quot;clearHistory&quot;:false}"></div>'
# rubocop:enable Layout/LineLength
end
end
end
Expand Down

0 comments on commit 1413358

Please sign in to comment.