2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2013-06-22 04:31:40 +08:00
|
|
|
|
|
|
|
describe TopMenuItem do
|
2017-07-07 12:18:53 +08:00
|
|
|
before do
|
|
|
|
SiteSetting.top_menu = 'one,-nope|two|three,-not|four,ignored|latest|category/xyz'
|
|
|
|
end
|
|
|
|
|
2013-06-22 04:31:40 +08:00
|
|
|
let(:items) { SiteSetting.top_menu_items }
|
|
|
|
|
|
|
|
it 'has name' do
|
|
|
|
expect(items[0].name).to eq('one')
|
|
|
|
expect(items[1].name).to eq('two')
|
|
|
|
expect(items[2].name).to eq('three')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a filter' do
|
|
|
|
expect(items[0].filter).to eq('nope')
|
2014-09-25 23:44:48 +08:00
|
|
|
expect(items[0].has_filter?).to be_truthy
|
2013-06-22 04:31:40 +08:00
|
|
|
expect(items[2].filter).to eq('not')
|
2014-09-25 23:44:48 +08:00
|
|
|
expect(items[2].has_filter?).to be_truthy
|
2013-06-22 04:31:40 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not have a filter' do
|
|
|
|
expect(items[1].filter).to be_nil
|
2014-09-25 23:44:48 +08:00
|
|
|
expect(items[1].has_filter?).to be_falsey
|
2013-06-22 04:31:40 +08:00
|
|
|
expect(items[3].filter).to be_nil
|
2014-09-25 23:44:48 +08:00
|
|
|
expect(items[3].has_filter?).to be_falsey
|
2013-06-22 04:31:40 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has a specific category" do
|
2014-09-25 23:44:48 +08:00
|
|
|
expect(items.first.has_specific_category?).to be_falsey
|
|
|
|
expect(items.last.has_specific_category?).to be_truthy
|
2013-06-22 04:31:40 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not have a specific category" do
|
|
|
|
expect(items.first.specific_category).to be_nil
|
|
|
|
expect(items.last.specific_category).to eq('xyz')
|
|
|
|
end
|
|
|
|
|
2014-01-31 21:36:00 +08:00
|
|
|
end
|