diaspora/features/support/paths.rb
Florian Staudacher 1924c40d38 replace vendored backbone.js/underscore.js with 'backbone-on-rails' gem
- updates underscore to 1.5.2 and backbone to 1.1.0

backbone had some breaking changes:
- fix url/urlRoot handling in models & collections
- options are no longer attached to the view by default
- collections reset when 'fetch' is called, tell it to keep the existing
  models

other changes:
- fix some events triggering multiple times in connection with deleting
  a model
- use document fragments instead of an element array for stream entries
- adapt jasmine and cucumber specs to the changed code
  * no longer test the backbone router as part of our code
  * jasmine factory already returns model instances, no need to wrap
    that again
2014-01-16 23:23:30 +01:00

70 lines
2 KiB
Ruby

module NavigationHelpers
def path_to(page_name)
case page_name
when /^person_photos page$/
person_photos_path(@me.person)
when /^the home(?: )?page$/
stream_path
when /^step (\d)$/
if $1.to_i == 1
getting_started_path
else
getting_started_path(:step => $1)
end
when /^the tag page for "([^\"]*)"$/
tag_path($1)
when /^its ([\w ]+) page$/
send("#{$1.gsub(/\W+/, '_')}_path", @it)
when /^the ([\w ]+) page$/
send("#{$1.gsub(/\W+/, '_')}_path")
when /^my edit profile page$/
edit_profile_path
when /^my profile page$/
person_path(@me.person)
when /^my acceptance form page$/
invite_code_path(InvitationCode.first)
when /^the requestors profile$/
person_path(Request.where(:recipient_id => @me.person.id).first.sender)
when /^"([^\"]*)"'s page$/
p = User.find_by_email($1).person
{ path: person_path(p),
# '.diaspora_handle' on desktop, '.description' on mobile
special_elem: { selector: '.diaspora_handle, .description', text: p.diaspora_handle }
}
when /^my account settings page$/
edit_user_path
when /^my new profile page$/
person_path(@me.person, :ex => true)
when /^the new stream$/
stream_path(:ex => true)
when /^forgot password page$/
new_user_password_path
when /^"(\/.*)"/
$1
else
raise "Can't find mapping from \"#{page_name}\" to a path."
end
end
def login_page
path_to "the new user session page"
end
def post_path_by_content(text)
p = Post.find_by_text(text)
post_path(p)
end
def navigate_to(page_name)
path = path_to(page_name)
unless path.is_a?(Hash)
visit(path)
else
visit(path[:path])
await_elem = path[:special_elem]
find(await_elem.delete(:selector), await_elem)
end
end
end
World(NavigationHelpers)