Cucumber/spec cleanup. Removed some stray aspect.firsts, which should improve reliability across databases. Removed some cucumber steps we don't use & consolidated duplicate steps.
This commit is contained in:
parent
58161b006a
commit
2d6c2f0b60
9 changed files with 51 additions and 128 deletions
|
|
@ -8,7 +8,7 @@ Feature: Close Account
|
||||||
Given I am signed in
|
Given I am signed in
|
||||||
When I click on my name in the header
|
When I click on my name in the header
|
||||||
And I follow "settings"
|
And I follow "settings"
|
||||||
And I click ok in the confirm dialog to appear next
|
And I preemptively confirm the alert
|
||||||
And I follow "Close Account"
|
And I follow "Close Account"
|
||||||
Then I should be on the home page
|
Then I should be on the home page
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ Feature: Close Account
|
||||||
Then I sign in as "bob@bob.bob"
|
Then I sign in as "bob@bob.bob"
|
||||||
When I click on my name in the header
|
When I click on my name in the header
|
||||||
And I follow "settings"
|
And I follow "settings"
|
||||||
And I click ok in the confirm dialog to appear next
|
And I preemptively confirm the alert
|
||||||
And I follow "Close Account"
|
And I follow "Close Account"
|
||||||
Then I sign in as "alice@alice.alice"
|
Then I sign in as "alice@alice.alice"
|
||||||
And I am on the home page
|
And I am on the home page
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ Feature: User manages contacts
|
||||||
And I follow "People"
|
And I follow "People"
|
||||||
And I follow "Edit People"
|
And I follow "Edit People"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I click ok in the confirm dialog to appear next
|
And I preemptively confirm the alert
|
||||||
And I press "Delete" in the modal window
|
And I press "Delete" in the modal window
|
||||||
Then I should be on the contacts page
|
Then I should be on the contacts page
|
||||||
And I should not see "People" within "#aspect_nav"
|
And I should not see "People" within "#aspect_nav"
|
||||||
|
|
@ -37,7 +37,7 @@ Feature: User manages contacts
|
||||||
When I am on the home page
|
When I am on the home page
|
||||||
And I click on "People" aspect edit icon
|
And I click on "People" aspect edit icon
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I click ok in the confirm dialog to appear next
|
And I preemptively confirm the alert
|
||||||
And I press "Delete" in the modal window
|
And I press "Delete" in the modal window
|
||||||
Then I should be on the aspects page
|
Then I should be on the aspects page
|
||||||
And I should not see "People" within "#aspect_nav"
|
And I should not see "People" within "#aspect_nav"
|
||||||
|
|
@ -58,8 +58,9 @@ Feature: User manages contacts
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
Then I should have 0 contacts in "Cat People"
|
Then I should have 0 contacts in "Cat People"
|
||||||
|
|
||||||
Scenario: scrolling through contacts index
|
Scenario: infinite scroll on contacts index
|
||||||
Given I am signed in
|
Given I am signed in
|
||||||
|
And I resize my window to 800x600
|
||||||
And I have 60 contacts
|
And I have 60 contacts
|
||||||
And I am on the contacts page
|
And I am on the contacts page
|
||||||
Then I should see 25 contacts
|
Then I should see 25 contacts
|
||||||
|
|
@ -70,7 +71,6 @@ Feature: User manages contacts
|
||||||
When I scroll down
|
When I scroll down
|
||||||
Then I should see 60 contacts
|
Then I should see 60 contacts
|
||||||
|
|
||||||
|
|
||||||
Scenario: clicking on the contacts link in the header with zero contacts directs a user to the featured users page
|
Scenario: clicking on the contacts link in the header with zero contacts directs a user to the featured users page
|
||||||
Given I am signed in
|
Given I am signed in
|
||||||
And I have 0 contacts
|
And I have 0 contacts
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ Feature: posting
|
||||||
Scenario: post to all aspects
|
Scenario: post to all aspects
|
||||||
Given I expand the publisher
|
Given I expand the publisher
|
||||||
When I fill in "status_message_fake_text" with "I am eating a yogurt"
|
When I fill in "status_message_fake_text" with "I am eating a yogurt"
|
||||||
And I press "Share"
|
And I press "Share"
|
||||||
And I follow "Your Aspects"
|
And I follow "Your Aspects"
|
||||||
Then I should see "I am eating a yogurt" within ".stream_element"
|
Then I should see "I am eating a yogurt" within ".stream_element"
|
||||||
|
|
||||||
Scenario: post a photo without text
|
Scenario: post a photo without text
|
||||||
|
|
@ -90,43 +90,43 @@ Feature: posting
|
||||||
Scenario: hide a post
|
Scenario: hide a post
|
||||||
Given I expand the publisher
|
Given I expand the publisher
|
||||||
When I fill in "status_message_fake_text" with "Here is a post for you to hide"
|
When I fill in "status_message_fake_text" with "Here is a post for you to hide"
|
||||||
And I press "Share"
|
And I press "Share"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
|
|
||||||
And I log out
|
And I log out
|
||||||
And I sign in as "alice@alice.alice"
|
And I sign in as "alice@alice.alice"
|
||||||
And I am on "bob@bob.bob"'s page
|
And I am on "bob@bob.bob"'s page
|
||||||
|
|
||||||
And I hover over the ".stream_element"
|
And I hover over the ".stream_element"
|
||||||
And I preemptively confirm the alert
|
And I preemptively confirm the alert
|
||||||
And I click to delete the first post
|
And I click to delete the first post
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I go to "bob@bob.bob"'s page
|
And I go to "bob@bob.bob"'s page
|
||||||
Then I should not see "Here is a post for you to hide"
|
Then I should not see "Here is a post for you to hide"
|
||||||
And I am on the aspects page
|
And I am on the aspects page
|
||||||
Then I should not see "Here is a post for you to hide"
|
Then I should not see "Here is a post for you to hide"
|
||||||
|
|
||||||
Scenario: delete a post
|
Scenario: delete a post
|
||||||
Given I expand the publisher
|
Given I expand the publisher
|
||||||
When I fill in "status_message_fake_text" with "I am eating a yogurt"
|
When I fill in "status_message_fake_text" with "I am eating a yogurt"
|
||||||
And I press "Share"
|
And I press "Share"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I follow "Your Aspects"
|
And I follow "Your Aspects"
|
||||||
And I hover over the ".stream_element"
|
And I hover over the ".stream_element"
|
||||||
And I preemptively confirm the alert
|
And I preemptively confirm the alert
|
||||||
And I click to delete the first post
|
And I click to delete the first post
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I follow "Your Aspects"
|
And I follow "Your Aspects"
|
||||||
Then I should not see "I am eating a yogurt"
|
Then I should not see "I am eating a yogurt"
|
||||||
|
|
||||||
Scenario Outline: post to one aspect
|
Scenario Outline: post to one aspect
|
||||||
When I follow "PostTo"
|
When I follow "PostTo"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I expand the publisher
|
And I expand the publisher
|
||||||
And I fill in "status_message_fake_text" with "I am eating a yogurt"
|
And I fill in "status_message_fake_text" with "I am eating a yogurt"
|
||||||
And I press "Share"
|
And I press "Share"
|
||||||
And I am on the aspects page
|
And I am on the aspects page
|
||||||
And I follow "<aspect>" within "#aspect_nav"
|
And I follow "<aspect>" within "#aspect_nav"
|
||||||
Then I should <see> "I am eating a yogurt"
|
Then I should <see> "I am eating a yogurt"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
|
||||||
|
|
@ -61,10 +61,6 @@ When /^I click to delete the first post$/ do
|
||||||
page.execute_script('$(".stream_element").first().find(".stream_element_delete").first().click()')
|
page.execute_script('$(".stream_element").first().find(".stream_element_delete").first().click()')
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I click to delete the ([\d])(nd|rd|st|th) post$/ do |number, stuff|
|
|
||||||
page.execute_script('$(".stream_element:nth-child('+ number +'").first().find(".stream_element_delete").first().click()')
|
|
||||||
end
|
|
||||||
|
|
||||||
When /^I click to delete the first comment$/ do
|
When /^I click to delete the first comment$/ do
|
||||||
page.execute_script('$(".comment.posted").first().find(".comment_delete").click()')
|
page.execute_script('$(".comment.posted").first().find(".comment_delete").click()')
|
||||||
end
|
end
|
||||||
|
|
@ -91,12 +87,6 @@ When /^(.*) in the modal window$/ do |action|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(.*) in the aspect list$/ do |action|
|
|
||||||
within('#aspect_list') do
|
|
||||||
When action
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
When /^I press the first "([^"]*)"(?: within "([^"]*)")?$/ do |link_selector, within_selector|
|
When /^I press the first "([^"]*)"(?: within "([^"]*)")?$/ do |link_selector, within_selector|
|
||||||
with_scope(within_selector) do
|
with_scope(within_selector) do
|
||||||
find(:css, link_selector).click
|
find(:css, link_selector).click
|
||||||
|
|
@ -121,12 +111,6 @@ Then /^(?:|I )should not see a "([^\"]*)"(?: within "([^\"]*)")?$/ do |selector,
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^\"]*)" in the main content area$/ do |stuff|
|
|
||||||
within("#main_stream") do
|
|
||||||
Then "I should see #{stuff}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
When /^I wait for the ajax to finish$/ do
|
When /^I wait for the ajax to finish$/ do
|
||||||
wait_until(10) { evaluate_script("$.active") == 0 }
|
wait_until(10) { evaluate_script("$.active") == 0 }
|
||||||
end
|
end
|
||||||
|
|
@ -151,12 +135,6 @@ When /^I attach the file "([^\"]*)" to hidden element "([^\"]*)"(?: within "([^\
|
||||||
JS
|
JS
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I click ok in the confirm dialog to appear next$/ do
|
|
||||||
evaluate_script <<-JS
|
|
||||||
window.confirm = function() { return true; };
|
|
||||||
JS
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^I should get download alert$/ do
|
Then /^I should get download alert$/ do
|
||||||
page.evaluate_script("window.alert = function() { return true; }")
|
page.evaluate_script("window.alert = function() { return true; }")
|
||||||
end
|
end
|
||||||
|
|
@ -170,15 +148,6 @@ When /^I search for "([^\"]*)"$/ do |search_term|
|
||||||
JS
|
JS
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should( not)? see an add contact button$/ do |not_see|
|
|
||||||
expected_length = not_see ? 0 : 1
|
|
||||||
evaluate_script("$('.add_contact a').length == #{expected_length};")
|
|
||||||
end
|
|
||||||
|
|
||||||
When /^I click on the add contact button$/ do
|
|
||||||
page.execute_script("$('.add_contact a').click();")
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^the "([^"]*)" field(?: within "([^"]*)")? should be filled with "([^"]*)"$/ do |field, selector, value|
|
Then /^the "([^"]*)" field(?: within "([^"]*)")? should be filled with "([^"]*)"$/ do |field, selector, value|
|
||||||
with_scope(selector) do
|
with_scope(selector) do
|
||||||
field = find_field(field)
|
field = find_field(field)
|
||||||
|
|
@ -206,14 +175,6 @@ And /^I scroll down$/ do
|
||||||
wait_until(10) { evaluate_script('$("#infscr-loading:visible").length') == 0 }
|
wait_until(10) { evaluate_script('$("#infscr-loading:visible").length') == 0 }
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I wait for (\d+) seconds?$/ do |seconds|
|
|
||||||
sleep seconds.to_i
|
|
||||||
end
|
|
||||||
|
|
||||||
When /^I click the notification badge$/ do
|
|
||||||
find(:css, "#notification_badge a").click
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^the notification dropdown should be visible$/ do
|
Then /^the notification dropdown should be visible$/ do
|
||||||
find(:css, "#notification_dropdown").should be_visible
|
find(:css, "#notification_dropdown").should be_visible
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,7 @@ When 'I debug' do
|
||||||
debugger
|
debugger
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I wait for (\d+) seconds?$/ do |seconds|
|
||||||
|
sleep seconds.to_i
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
And /^Alice has a post mentioning Bob$/ do
|
And /^Alice has a post mentioning Bob$/ do
|
||||||
alice = User.find_by_email 'alice@alice.alice'
|
alice = User.find_by_email 'alice@alice.alice'
|
||||||
bob = User.find_by_email 'bob@bob.bob'
|
bob = User.find_by_email 'bob@bob.bob'
|
||||||
aspect = alice.aspects.first
|
aspect = alice.aspects.where(:name => "Besties").first
|
||||||
alice.post(:status_message, :text => "@{Bob Jones; #{bob.person.diaspora_handle}}", :to => alice.aspects.first)
|
alice.post(:status_message, :text => "@{Bob Jones; #{bob.person.diaspora_handle}}", :to => aspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I fill in a mention for bob into the publisher$/ do
|
|
||||||
bob = User.find_by_email 'bob@bob.bob'
|
|
||||||
And 'I fill in "status_message_fake_text" with "Hi, @{Bob Jones; #{bob.person.diaspora_handle}} long time no see'
|
|
||||||
end
|
|
||||||
|
|
@ -1,14 +1,3 @@
|
||||||
Given /^I am signed in as the following (\w+):$/ do |role, table|
|
|
||||||
Given %(the following #{role}:), table
|
|
||||||
@me = @it
|
|
||||||
Given 'I am signed in'
|
|
||||||
end
|
|
||||||
|
|
||||||
Given /^I (?:am signed|sign) in as an? (\w+)$/ do |role|
|
|
||||||
@me = Factory(role.to_sym)
|
|
||||||
Given 'I am signed in'
|
|
||||||
end
|
|
||||||
|
|
||||||
Given /^(?:I am signed in|I sign in)$/ do
|
Given /^(?:I am signed in|I sign in)$/ do
|
||||||
When %(I try to sign in)
|
When %(I try to sign in)
|
||||||
wait_until { page.has_content?("#{@me.first_name} #{@me.last_name}") }
|
wait_until { page.has_content?("#{@me.first_name} #{@me.last_name}") }
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,6 @@ Given /^a user with username "([^\"]*)" and password "([^\"]*)"$/ do |username,
|
||||||
@me.reload
|
@me.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^that I am a rock star$/ do
|
|
||||||
Given('a user with username "awesome" and password "totallyawesome"')
|
|
||||||
end
|
|
||||||
|
|
||||||
Given /^a user with email "([^\"]*)"$/ do |email|
|
Given /^a user with email "([^\"]*)"$/ do |email|
|
||||||
user = Factory(:user, :email => email, :password => 'password',
|
user = Factory(:user, :email => email, :password => 'password',
|
||||||
:password_confirmation => 'password', :getting_started => false)
|
:password_confirmation => 'password', :getting_started => false)
|
||||||
|
|
@ -62,17 +58,6 @@ When /^I have user with username "([^"]*)" in an aspect called "([^"]*)"$/ do |u
|
||||||
contact.aspects << @me.aspects.find_by_name(aspect)
|
contact.aspects << @me.aspects.find_by_name(aspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
Given /^I have one follower$/ do
|
|
||||||
other_user = Factory(:user)
|
|
||||||
other_aspect = other_user.aspects.create!(:name => "meh")
|
|
||||||
other_user.share_with(@me.person, other_aspect)
|
|
||||||
|
|
||||||
other_user.reload
|
|
||||||
other_aspect.reload
|
|
||||||
@me.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
Given /^a user with email "([^"]*)" is connected with "([^"]*)"$/ do |arg1, arg2|
|
Given /^a user with email "([^"]*)" is connected with "([^"]*)"$/ do |arg1, arg2|
|
||||||
user1 = User.where(:email => arg1).first
|
user1 = User.where(:email => arg1).first
|
||||||
user2 = User.where(:email => arg2).first
|
user2 = User.where(:email => arg2).first
|
||||||
|
|
@ -82,7 +67,7 @@ end
|
||||||
Given /^a user with username "([^"]*)" is connected with "([^"]*)"$/ do |arg1, arg2|
|
Given /^a user with username "([^"]*)" is connected with "([^"]*)"$/ do |arg1, arg2|
|
||||||
user1 = User.where(:username => arg1).first
|
user1 = User.where(:username => arg1).first
|
||||||
user2 = User.where(:username => arg2).first
|
user2 = User.where(:username => arg2).first
|
||||||
connect_users(user1, user1.aspects.first, user2, user2.aspects.first)
|
connect_users(user1, user1.aspects.where(:name => "Besties").first, user2, user2.aspects.where(:name => "Besties").first)
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^there is a user "([^\"]*)" who's tagged "([^\"]*)"$/ do |full_name, tag|
|
Given /^there is a user "([^\"]*)" who's tagged "([^\"]*)"$/ do |full_name, tag|
|
||||||
|
|
@ -101,7 +86,7 @@ Given /^many posts from alice for bob$/ do
|
||||||
time_fulcrum = Time.now - 40000
|
time_fulcrum = Time.now - 40000
|
||||||
time_interval = 1000
|
time_interval = 1000
|
||||||
(1..40).each do |n|
|
(1..40).each do |n|
|
||||||
post = alice.post :status_message, :text => "#{alice.username} - #{n} - #seeded", :to => alice.aspects.first.id
|
post = alice.post :status_message, :text => "#{alice.username} - #{n} - #seeded", :to => alice.aspects.where(:name => "generic").first.id
|
||||||
post.created_at = time_fulcrum - time_interval
|
post.created_at = time_fulcrum - time_interval
|
||||||
post.updated_at = time_fulcrum + time_interval
|
post.updated_at = time_fulcrum + time_interval
|
||||||
post.save
|
post.save
|
||||||
|
|
@ -122,19 +107,6 @@ When /^I (add|remove|toggle) the person (to|from) my ([\d])(nd|rd|st|th) aspect$
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I add the person to a new aspect called "([^\"]*)"$/ do |aspect_name|
|
|
||||||
steps %Q{
|
|
||||||
And I press the first ".toggle.button"
|
|
||||||
|
|
||||||
And I press click ".new_aspect" within ".dropdown.active"
|
|
||||||
And I fill in "#aspect_name" with "#{aspect_name}"
|
|
||||||
And I submit the form
|
|
||||||
|
|
||||||
And I wait for the ajax to finish
|
|
||||||
And I press the first ".toggle.button"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
When /^I post a status with the text "([^\"]*)"$/ do |text|
|
When /^I post a status with the text "([^\"]*)"$/ do |text|
|
||||||
@me.post(:status_message, :text => text, :public => true, :to => 'all')
|
@me.post(:status_message, :text => text, :public => true, :to => 'all')
|
||||||
end
|
end
|
||||||
|
|
@ -191,9 +163,9 @@ Given /^I have (\d+) contacts$/ do |n|
|
||||||
Contact.import(contacts)
|
Contact.import(contacts)
|
||||||
contacts = @me.contacts.limit(n.to_i)
|
contacts = @me.contacts.limit(n.to_i)
|
||||||
|
|
||||||
aspect_id = @me.aspects.first.id
|
aspect_id = @me.aspects.length == 1 ? @me.aspects.first.id : @me.aspects.where(:name => "Besties").first.id
|
||||||
contacts.each do |contact|
|
contacts.each do |contact|
|
||||||
aspect_memberships << AspectMembership.new(:contact_id => contact.id, :aspect_id => @me.aspects.first.id)
|
aspect_memberships << AspectMembership.new(:contact_id => contact.id, :aspect_id => aspect_id)
|
||||||
end
|
end
|
||||||
AspectMembership.import(aspect_memberships)
|
AspectMembership.import(aspect_memberships)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
module HelperMethods
|
module HelperMethods
|
||||||
def connect_users_with_aspects(u1,u2)
|
def connect_users_with_aspects(u1, u2)
|
||||||
connect_users(u1, u1.aspects.first, u2, u2.aspects.first)
|
aspect1 = u1.aspects.length == 1 ? u1.aspects.first : u1.aspects.where(:name => "Besties").first
|
||||||
|
aspect2 = u2.aspects.length == 1 ? u2.aspects.first : u2.aspects.where(:name => "Besties").first
|
||||||
|
connect_users(u1, aspect1, u2, aspect2)
|
||||||
end
|
end
|
||||||
def connect_users(user1, aspect1, user2, aspect2)
|
def connect_users(user1, aspect1, user2, aspect2)
|
||||||
user1.contacts.create!(:person => user2.person,
|
user1.contacts.create!(:person => user2.person,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue