permission_steps.rb revision f7670322c267c298084c3b40ed196cdf9a1f2bc7
Given(/^there exists a repository$/) do
@repository = FactoryGirl.create :repository
end
Given(/^a User with a permission$/) do
@user = FactoryGirl.create :user
FactoryGirl.create :permission, subject: @user, item: @repository
end
Given(/^a team$/) do
@team = FactoryGirl.create :team
end
Given(/^I am logged in$/) do
visit root_path
login_as @user, :scope => :user
end
When(/^I visit the permissions page of my repository$/) do
visit repository_permissions_path(@repository)
end
When(/^I fill in the name of an team$/) do
within '.relationList' do
# does only one permission exist?
1.should ==(all('ul li[data-id]').count)
# fill in the autocomplete input
fill_in 'name', with: @team.name
end
end
When(/^click on the suggested team$/) do
pending #should work but it doesent
# trigger the autocomplete input
page.execute_script %Q{ $('#name').trigger("mouseenter").trigger("click"); }
# select the first suggestion
page.execute_script %Q{ $('li.ui-menu-item a').trigger('mouseenter').click(); }
end
Then(/^the permission for the team should be added$/) do
# has the permission been added to the list?
page.should have_link @team.name
within '.relationList ul' do
2.should ==(all('li[data-id]').count)
end
end