-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate detected instance_variable is an ActiveRecord::Relation
- Loading branch information
Showing
8 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
lib/bulletmark_repairer/monkey_patches/action_view/base.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module BulletmarkRepairer | ||
module ActionView | ||
module Base | ||
def initialize(*args) | ||
super(*args) | ||
@_assigns.each do |ivname, value| | ||
BulletmarkRepairer::Thread.memorize_instance_variable_name(name: ivname, value: value) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
spec/fake_app/app/controllers/instance_variables_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class InstanceVariablesController < ActionController::Base | ||
def index | ||
@favorite = true | ||
@plays = Play.all | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% plays = @plays %> | ||
<% if @favorite %> | ||
<% plays.each do |play| %> | ||
<% play.actors.each do |actor| %> | ||
<%= actor.name %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe InstanceVariablesController do | ||
let(:original_src) do | ||
<<-SRC | ||
def index | ||
@favorite = true | ||
@plays = Play.all | ||
end | ||
SRC | ||
end | ||
let(:patched_src) do | ||
<<-SRC | ||
def index | ||
@favorite = true | ||
@plays = Play.all.includes([:actors]) | ||
end | ||
SRC | ||
end | ||
|
||
before do | ||
create(:play, :blast) | ||
create(:play, :crescent_wolf) | ||
end | ||
|
||
subject { get instance_variables_path } | ||
|
||
it_behaves_like 'correctly patched' | ||
end |