Skip to content

Commit

Permalink
Edit existing specs of _new and _discover button classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila Vecerek committed Feb 17, 2017
1 parent afbed58 commit a8c5d76
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
14 changes: 9 additions & 5 deletions spec/helpers/application_helper/buttons/ab_button_new_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
describe ApplicationHelper::Button::AbButtonNew do
subject { described_class.new(view_context, {}, {}, {}) }
let(:view_context) { setup_view_context_with_sandbox(:active_tree => tree) }
let(:tree) { :not_ab_tree }
let(:lastaction) { '' }
let(:display) { '' }
let(:x_node) { 'xx-ab_12345' }
subject { described_class.new(view_context, {}, {'lastaction' => lastaction, 'display' => display}, {}) }

before { allow(view_context).to receive(:x_node).and_return(x_node) }

it_behaves_like 'a _new or _discover button'

describe '#visible?' do
context 'when x_active_tree != :ab_tree' do
let(:view_context) { setup_view_context_with_sandbox(:active_tree => :not_ab_tree) }
let(:x_node) { 'xx-ab_11784' }
it { expect(subject.visible?).to be_truthy }
end
context 'when x_active_tree == :ab_tree' do
let(:view_context) { setup_view_context_with_sandbox(:active_tree => :ab_tree) }
let(:tree) { :ab_tree }
context ' and x_node cannot be split into 2 parts' do
let(:x_node) { 'xx-ab' }
it { expect(subject.visible?).to be_truthy }
Expand All @@ -20,7 +25,6 @@
it { expect(subject.visible?).to be_truthy }
end
context 'and x_node looks like xx-ab_12345' do
let(:x_node) { 'xx-ab_12345' }
it { expect(subject.visible?).to be_falsey }
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
describe ApplicationHelper::Button::CustomizationTemplateNew do
let(:view_context) { setup_view_context_with_sandbox({}) }
subject { described_class.new(view_context, {}, {}, {}) }
let(:lastaction) { '' }
let(:display) { '' }
let(:x_node) { 'root' }
subject { described_class.new(view_context, {}, {'lastaction' => lastaction, 'display' => display}, {}) }

before { allow(view_context).to receive(:x_node).and_return(x_node) }

it_behaves_like 'a _new or _discover button'

describe '#visible?' do
context 'when root node is active' do
let(:x_node) { 'root' }
it { expect(subject.visible?).to be_truthy }
end
context 'when system node is active' do
Expand Down
8 changes: 6 additions & 2 deletions spec/helpers/application_helper/buttons/widget_new_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
describe ApplicationHelper::Button::WidgetNew do
let(:view_context) { setup_view_context_with_sandbox({}) }
subject { described_class.new(view_context, {}, {}, {}) }
let(:lastaction) { '' }
let(:display) { '' }
let(:x_node) { 'not_root' }
subject { described_class.new(view_context, {}, {'lastaction' => lastaction, 'display' => display}, {}) }

before { allow(view_context).to receive(:x_node).and_return(x_node) }

it_behaves_like 'a _new or _discover button'

describe '#visible?' do
context 'when x_node == root' do
let(:x_node) { 'root' }
it { expect(subject.visible?).to be_falsey }
end
context 'when x_node != root' do
let(:x_node) { 'not_root' }
it { expect(subject.visible?).to be_truthy }
end
end
Expand Down

0 comments on commit a8c5d76

Please sign in to comment.