only show connect to services if all services not already connected

This commit is contained in:
danielgrippi 2011-08-03 19:02:47 -07:00
parent 001d4ceaff
commit 6a56e3298c
3 changed files with 26 additions and 1 deletions

View file

@ -133,4 +133,8 @@ module ApplicationHelper
featured_users_path
end
end
def all_services_connected?
current_user.services.size == AppConfig[:configured_services].size
end
end

View file

@ -22,7 +22,7 @@
= t('aspects.index.cubbies.explanation')
= link_to t('aspects.index.cubbies.learn_more'), token_path
- unless AppConfig.configured_services.blank?
- unless AppConfig.configured_services.blank? || all_services_connected?
.section
.title
= image_tag('/images/icons/monotone_wrench_settings.png')

View file

@ -77,4 +77,25 @@ describe ApplicationHelper do
contacts_link.should == contacts_path
end
end
describe "#all_services_connected?" do
before do
AppConfig[:configured_services] = [1, 2, 3]
def current_user
@current_user
end
@current_user = alice
end
it 'returns true if all networks are connected' do
3.times { |t| @current_user.services << Factory.build(:service) }
all_services_connected?.should be_true
end
it 'returns false if not all networks are connected' do
@current_user.services.delete_all
all_services_connected?.should be_false
end
end
end