Skip to content

Commit 321f90c

Browse files
jonathanphilippoujustin808
authored andcommitted
Logging trace set to false was ignored (#845)
* Fixed bug where "false" data attribute was a truthy value. * Fix is to use nil if the value is false.
1 parent 8a3279b commit 321f90c

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]
66
## [Unreleased]
77
*Please add entries here for your pull requests.*
88

9+
## Changed
10+
- Logging no longer occurs when trace is turned to false. [#845](https://github.com/shakacode/react_on_rails/pull/845) by [conturbo](https://github.com/Conturbo)
11+
912
## [8.0.0-beta.2] - 2017-05-08
1013

1114
### Changed

app/helpers/react_on_rails_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def react_component(component_name, raw_options = {})
111111
type: "application/json",
112112
class: "js-react-on-rails-component",
113113
"data-component-name" => options.name,
114-
"data-trace" => options.trace,
114+
"data-trace" => (options.trace ? true : nil),
115115
"data-dom-id" => options.dom_id)
116116

117117
# Create the HTML rendering part

spec/dummy/spec/features/rails_context_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
i18nLocale: "en",
3131
i18nDefaultLocale: "en",
3232
httpAcceptLanguage: http_accept_language,
33+
# railsEnv: Rails.env,
3334
somethingUseful: "REALLY USEFUL"
3435
}
3536

spec/dummy/spec/helpers/react_on_rails_helper_spec.rb

+19-3
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@
8383
let(:react_definition_script) do
8484
<<-SCRIPT
8585
<script type="application/json" class="js-react-on-rails-component" data-component-name="App" \
86-
data-trace="false" data-dom-id="App-react-component-0">{"name":"My Test Name"}</script>
86+
data-dom-id="App-react-component-0">{"name":"My Test Name"}</script>
8787
SCRIPT
8888
end
8989

9090
let(:react_definition_script_no_params) do
9191
<<-SCRIPT
9292
<script type="application/json" class="js-react-on-rails-component" data-component-name="App" \
93-
data-trace="false" data-dom-id="App-react-component-0">{}</script>
93+
data-dom-id="App-react-component-0">{}</script>
9494
SCRIPT
9595
end
9696

@@ -131,14 +131,30 @@
131131
let(:react_definition_script) do
132132
<<-SCRIPT
133133
<script type="application/json" class="js-react-on-rails-component" data-component-name="App" \
134-
data-trace="false" data-dom-id="shaka_div">{"name":"My Test Name"}</script>
134+
data-dom-id="shaka_div">{"name":"My Test Name"}</script>
135135
SCRIPT
136136
end
137137

138138
it { is_expected.to include id }
139139
it { is_expected.not_to include react_component_div }
140140
it { is_expected.to include react_definition_script }
141141
end
142+
143+
context "with 'trace' == true" do
144+
it "adds the data-trace tag to the component_specification_tag" do
145+
result = react_component("App", trace: true)
146+
147+
expect(result).to match(/data-trace="true"/)
148+
end
149+
end
150+
151+
context "with 'trace' == false" do
152+
it "does not add the data-trace tag" do
153+
result = react_component("App", trace: false)
154+
155+
expect(result).not_to match(/data-trace=/)
156+
end
157+
end
142158
end
143159

144160
describe "#redux_store" do

0 commit comments

Comments
 (0)