Commit 38f43812 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Unify spec/features/projects/actve_tabs_spec.rb

parent 57c6bf60
require 'spec_helper'
describe 'Project active tab' do
let(:user) { create :user }
let(:project) { create(:project, :repository) }
before do
project.add_master(user)
sign_in(user)
end
def click_tab(title)
page.within '.sidebar-top-level-items > .active' do
click_link(title)
end
end
shared_examples 'page has active tab' do |title|
it "activates #{title} tab" do
expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
expect(find('.sidebar-top-level-items > li.active')).to have_content(title)
end
end
shared_examples 'page has active sub tab' do |title|
it "activates #{title} sub tab" do
expect(page).to have_selector('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)', count: 1)
expect(find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)'))
.to have_content(title)
end
end
context 'on project Home' do
before do
visit project_path(project)
end
it_behaves_like 'page has active tab', 'Overview'
context 'on project Home/Activity' do
before do
click_tab('Activity')
end
it_behaves_like 'page has active tab', 'Overview'
end
end
end
......@@ -35,7 +35,7 @@ describe 'Project active tab' do
visit project_path(project)
end
it_behaves_like 'page has active tab', 'Overview'
it_behaves_like 'page has active tab', 'Project'
it_behaves_like 'page has active sub tab', 'Details'
context 'on project Home/Activity' do
......@@ -43,7 +43,7 @@ describe 'Project active tab' do
click_tab('Activity')
end
it_behaves_like 'page has active tab', 'Overview'
it_behaves_like 'page has active tab', 'Project'
it_behaves_like 'page has active sub tab', 'Activity'
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment