Skip to content

Commit

Permalink
Logging trace set to false was ignored (#845)
Browse files Browse the repository at this point in the history
* Fixed bug where "false" data attribute was a truthy value.
* Fix is to use nil if the value is false.
  • Loading branch information
jonathanphilippou authored and justin808 committed May 19, 2017
1 parent 8a3279b commit 321f90c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]
## [Unreleased]
*Please add entries here for your pull requests.*

## Changed
- 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)

## [8.0.0-beta.2] - 2017-05-08

### Changed
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/react_on_rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def react_component(component_name, raw_options = {})
type: "application/json",
class: "js-react-on-rails-component",
"data-component-name" => options.name,
"data-trace" => options.trace,
"data-trace" => (options.trace ? true : nil),
"data-dom-id" => options.dom_id)

# Create the HTML rendering part
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/spec/features/rails_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
i18nLocale: "en",
i18nDefaultLocale: "en",
httpAcceptLanguage: http_accept_language,
# railsEnv: Rails.env,
somethingUseful: "REALLY USEFUL"
}

Expand Down
22 changes: 19 additions & 3 deletions spec/dummy/spec/helpers/react_on_rails_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@
let(:react_definition_script) do
<<-SCRIPT
<script type="application/json" class="js-react-on-rails-component" data-component-name="App" \
data-trace="false" data-dom-id="App-react-component-0">{"name":"My Test Name"}</script>
data-dom-id="App-react-component-0">{"name":"My Test Name"}</script>
SCRIPT
end

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

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

it { is_expected.to include id }
it { is_expected.not_to include react_component_div }
it { is_expected.to include react_definition_script }
end

context "with 'trace' == true" do
it "adds the data-trace tag to the component_specification_tag" do
result = react_component("App", trace: true)

expect(result).to match(/data-trace="true"/)
end
end

context "with 'trace' == false" do
it "does not add the data-trace tag" do
result = react_component("App", trace: false)

expect(result).not_to match(/data-trace=/)
end
end
end

describe "#redux_store" do
Expand Down

0 comments on commit 321f90c

Please sign in to comment.