Skip to content

Commit

Permalink
Update is_advanced_tab? helper to recent changes
Browse files Browse the repository at this point in the history
We moved meta, pulse and project config related actions to individual
controllers. Therefore we have to update the advanced tabs as well.
  • Loading branch information
bgeuken committed Dec 12, 2018
1 parent 96d232c commit 1c80152
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/webui_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def description_wrapper(description)
end

def is_advanced_tab?
action_name.in?(['prjconf', 'index', 'meta', 'status', 'pulse'])
action_name.in?(['index', 'status']) || controller_name.in?(['project_configuration', 'meta', 'pulse'])
end

def sprite_tag(icon, opts = {})
Expand Down
25 changes: 22 additions & 3 deletions src/api/spec/helpers/webui/webui_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@
end

describe '#is_advanced_tab?' do
advanced_tabs = ['prjconf', 'index', 'meta', 'status']
advanced_tabs.each do |action|
advanced_tab_actions = ['index', 'status']
advanced_tab_actions.each do |action|
context "current action is '#{action}'" do
before do
allow(controller).to receive(:action_name).and_return(action)
Expand All @@ -226,13 +226,32 @@
end
end

context "current action is not within #{advanced_tabs}" do
context "current action is not within #{advanced_tab_actions}" do
before do
allow(controller).to receive(:action_name).and_return('some_action')
end

it { expect(is_advanced_tab?).to be(false) }
end

advanced_tab_controllers = ['project_configuration', 'meta', 'pulse']
advanced_tab_controllers.each do |controller_name|
context "current controller is '#{controller_name}'" do
before do
allow(controller).to receive(:controller_name).and_return(controller_name)
end

it { expect(is_advanced_tab?).to be(true) }
end
end

context "current controller is not within #{advanced_tab_controllers}" do
before do
allow(controller).to receive(:controller_name).and_return('some_controller')
end

it { expect(is_advanced_tab?).to be(false) }
end
end

describe '#next_codemirror_uid' do
Expand Down

0 comments on commit 1c80152

Please sign in to comment.