Merge branch 'master' of github.com:diaspora/diaspora into pivots
Conflicts: app/controllers/users_controller.rb app/models/user.rb config/sprinkle/provision.rb
This commit is contained in:
commit
f66b5f4006
25 changed files with 292 additions and 52 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
||||||
.idea
|
.idea
|
||||||
|
*.swap
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*~
|
*~
|
||||||
|
|
|
||||||
13
Gemfile
13
Gemfile
|
|
@ -1,9 +1,9 @@
|
||||||
source 'http://rubygems.org'
|
source 'http://rubygems.org'
|
||||||
|
|
||||||
gem 'rails', '3.0.0.rc'
|
#gem 'rails', '3.0.0.rc'
|
||||||
gem 'bundler', '1.0.0.rc.5'
|
#gem 'bundler', '1.0.0.rc.5'
|
||||||
#gem 'rails', '3.0.0.beta4'
|
gem 'rails', '3.0.0.beta4'
|
||||||
#gem 'bundler', '0.9.26'
|
gem 'bundler', '0.9.26'
|
||||||
|
|
||||||
#Security
|
#Security
|
||||||
gem 'devise', :git => 'http://github.com/BadMinus/devise.git'
|
gem 'devise', :git => 'http://github.com/BadMinus/devise.git'
|
||||||
|
|
@ -40,11 +40,14 @@ group :test do
|
||||||
gem 'rspec', '>= 2.0.0.beta.17'
|
gem 'rspec', '>= 2.0.0.beta.17'
|
||||||
gem 'rspec-rails', '2.0.0.beta.17'
|
gem 'rspec-rails', '2.0.0.beta.17'
|
||||||
gem 'mocha'
|
gem 'mocha'
|
||||||
gem 'webrat'
|
gem 'webrat', '0.7.2.beta.1'
|
||||||
gem 'redgreen'
|
gem 'redgreen'
|
||||||
gem 'autotest'
|
gem 'autotest'
|
||||||
gem 'factory_girl_rails'
|
gem 'factory_girl_rails'
|
||||||
gem 'database_cleaner'
|
gem 'database_cleaner'
|
||||||
|
gem 'saucelabs-adapter', '= 0.8.12'
|
||||||
|
gem 'selenium-rc'
|
||||||
|
gem 'json'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,10 @@ class PeopleController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@person = current_user.visible_person_by_id(params[:id])
|
@person = current_user.visible_person_by_id(params[:id])
|
||||||
@profile = @person.profile
|
@profile = @person.profile
|
||||||
@posts = Post.find_all_by_person_id(@person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
|
||||||
@latest_status_message = StatusMessage.newest_for(@person)
|
@posts = Post.where(:person_id => @person.id, :_id.in => current_user.visible_post_ids).paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
|
|
||||||
|
@latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last
|
||||||
@post_count = @posts.count
|
@post_count = @posts.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,10 @@ class RequestsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
puts params.inspect
|
||||||
rel_hash = relationship_flow(params[:request][:destination_url])
|
rel_hash = relationship_flow(params[:request][:destination_url])
|
||||||
Rails.logger.debug("Sending request: #{rel_hash}")
|
Rails.logger.debug("Sending request: #{rel_hash}")
|
||||||
@request = current_user.send_request(rel_hash, params[:request][:group])
|
@request = current_user.send_request(rel_hash, params[:request][:group_id])
|
||||||
|
|
||||||
if @request
|
if @request
|
||||||
flash[:notice] = "a friend request was sent to #{@request.destination_url}"
|
flash[:notice] = "a friend request was sent to #{@request.destination_url}"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,16 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
before_filter :authenticate_user!, :except => [:new, :create]
|
before_filter :authenticate_user!, :except => [:new, :create]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@groups_array = current_user.groups.collect{|x| [x.to_s, x.id]}
|
||||||
|
|
||||||
|
unless params[:q]
|
||||||
|
@people = Person.all
|
||||||
|
render :index
|
||||||
|
else
|
||||||
|
@people = Person.search(params[:q])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user= User.first(:id => params[:id])
|
@user= User.first(:id => params[:id])
|
||||||
|
|
@ -8,20 +19,19 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@user = User.first(:id => params[:id])
|
@user = User.first(:id => params[:id])
|
||||||
|
@person = @user.person
|
||||||
@profile = @user.profile
|
@profile = @user.profile
|
||||||
@photos = Photo.paginate :page => params[:page], :order => 'created_at DESC'
|
@photos = Photo.where(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@user = User.where(:id => params[:id]).first
|
@user = User.where(:id => params[:id]).first
|
||||||
|
|
||||||
if @user.update_profile(params[:user])
|
if @user.update_profile(params[:user])
|
||||||
flash[:notice] = "Successfully updated user."
|
flash[:notice] = "Successfully updated your profile"
|
||||||
redirect_to @user
|
redirect_to @user.person
|
||||||
else
|
else
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
11
app/helpers/people_helper.rb
Normal file
11
app/helpers/people_helper.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
module PeopleHelper
|
||||||
|
|
||||||
|
def search_or_index
|
||||||
|
if params[:q]
|
||||||
|
" results for #{params[:q]}"
|
||||||
|
else
|
||||||
|
" people on this pod"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module PhotosHelper
|
module PhotosHelper
|
||||||
|
|
||||||
def linked_scaled_photo(photo, album)
|
def linked_scaled_photo(photo, album)
|
||||||
link_to (image_tag photo.image.url(:scaled_full)), photo_path(album.next_photo(photo)), :rel => "prefetch"
|
link_to (image_tag photo.url(:scaled_full)), photo_path(album.next_photo(photo)), :rel => "prefetch"
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_prev(photo, album)
|
def link_to_prev(photo, album)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ module RequestsHelper
|
||||||
action = :none
|
action = :none
|
||||||
url = nil
|
url = nil
|
||||||
local_person = Person.by_webfinger identifier
|
local_person = Person.by_webfinger identifier
|
||||||
|
puts local_person.inspect
|
||||||
if local_person
|
if local_person
|
||||||
action = (local_person == current_user.person ? :none : :friend)
|
action = (local_person == current_user.person ? :none : :friend)
|
||||||
url = local_person.receive_url
|
url = local_person.receive_url
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ class Group
|
||||||
belongs_to :user, :class_name => 'User'
|
belongs_to :user, :class_name => 'User'
|
||||||
|
|
||||||
timestamps!
|
timestamps!
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class Post
|
||||||
|
|
||||||
#Querying
|
#Querying
|
||||||
def self.newest_for(person)
|
def self.newest_for(person)
|
||||||
self.first(:person_id => person.id, :order => '_id desc')
|
self.where(:person_id => person.id, :order => '_id desc')
|
||||||
end
|
end
|
||||||
|
|
||||||
#ENCRYPTION
|
#ENCRYPTION
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ class User
|
||||||
after_create :seed_groups
|
after_create :seed_groups
|
||||||
after_save :check_for_tommy
|
after_save :check_for_tommy
|
||||||
|
|
||||||
|
before_validation :do_bad_things
|
||||||
######## Making things work ########
|
######## Making things work ########
|
||||||
key :email, String
|
key :email, String
|
||||||
#validates_true_for :email, :logic => lambda {self.pivotal_email?}
|
#validates_true_for :email, :logic => lambda {self.pivotal_email?}
|
||||||
|
|
@ -307,6 +308,12 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
###Helpers############
|
###Helpers############
|
||||||
|
def self.instantiate!( opts = {} )
|
||||||
|
opts[:person][:email] = opts[:email]
|
||||||
|
opts[:person][:serialized_key] = generate_key
|
||||||
|
User.create!( opts)
|
||||||
|
end
|
||||||
|
|
||||||
def terse_url
|
def terse_url
|
||||||
terse= self.url.gsub(/https?:\/\//, '')
|
terse= self.url.gsub(/https?:\/\//, '')
|
||||||
terse.gsub!(/www\./, '')
|
terse.gsub!(/www\./, '')
|
||||||
|
|
@ -314,6 +321,10 @@ class User
|
||||||
terse
|
terse
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def do_bad_things
|
||||||
|
self.password_confirmation = self.password
|
||||||
|
end
|
||||||
|
|
||||||
def visible_person_by_id( id )
|
def visible_person_by_id( id )
|
||||||
id = ensure_bson id
|
id = ensure_bson id
|
||||||
return self.person if id == self.person.id
|
return self.person if id == self.person.id
|
||||||
|
|
@ -346,14 +357,22 @@ class User
|
||||||
id = ensure_bson person.id
|
id = ensure_bson person.id
|
||||||
groups.select {|group| group.person_ids.include? id}
|
groups.select {|group| group.person_ids.include? id}
|
||||||
end
|
end
|
||||||
|
<<<<<<< HEAD
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def setup_person
|
def setup_person
|
||||||
self.person.serialized_key ||= generate_key.export
|
self.person.serialized_key ||= generate_key.export
|
||||||
|
=======
|
||||||
|
|
||||||
|
def setup_person
|
||||||
|
self.person.serialized_key = generate_key.export
|
||||||
|
>>>>>>> 2e76987e259ff23455d00c077fd347b4376d7e0e
|
||||||
self.person.email = email
|
self.person.email = email
|
||||||
self.person.save!
|
self.person.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
def generate_key
|
def generate_key
|
||||||
OpenSSL::PKey::RSA::generate 1024
|
OpenSSL::PKey::RSA::generate 1024
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
%li.name= link_to current_user.real_name, current_user.person
|
%li.name= link_to current_user.real_name, current_user.person
|
||||||
%li= link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count)
|
%li= link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count)
|
||||||
%li= link_to "settings", edit_user_path(current_user)
|
%li= link_to "settings", edit_user_path(current_user)
|
||||||
|
%li= link_to "search", users_path
|
||||||
%li= link_to "logout", destroy_user_session_path
|
%li= link_to "logout", destroy_user_session_path
|
||||||
- else
|
- else
|
||||||
= link_to "login", new_user_session_path
|
= link_to "login", new_user_session_path
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
%h1.big_text
|
/ %h1.big_text
|
||||||
.back
|
/ .back
|
||||||
= link_to '⇧ home', root_path
|
/ = link_to '⇧ home', root_path
|
||||||
Friends
|
/ Friends
|
||||||
.button.right
|
/ .button.right
|
||||||
= link_to 'Add Friend', requests_path
|
/ = link_to 'Add Friend', requests_path
|
||||||
|
= @people.count.to_s + search_or_index
|
||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
%th real name
|
%th real name
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
|
|
||||||
%h1
|
%h1
|
||||||
= @person.real_name
|
= @person.real_name
|
||||||
- unless @person.id == current_user.id
|
- unless @person.id == current_user.person.id
|
||||||
|
|
||||||
.right
|
.right
|
||||||
= link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete, :class => "button"
|
= link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete, :class => "button"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@
|
||||||
|
|
||||||
Enter a Diaspora URL, Diaspora username, or random email address:
|
Enter a Diaspora URL, Diaspora username, or random email address:
|
||||||
= f.text_field :destination_url
|
= f.text_field :destination_url
|
||||||
= f.hidden_field :group, :value => @group.id
|
= f.hidden_field :group_id, :value => @group.id
|
||||||
= f.submit
|
= f.submit
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
|
%h1.big_text
|
||||||
|
.back
|
||||||
|
= link_to "⇧ home", root_path
|
||||||
|
|
||||||
|
Editing your profile
|
||||||
|
|
||||||
= form_for @user do |f|
|
= form_for @user do |f|
|
||||||
|
|
||||||
%h1.big_text
|
|
||||||
.back
|
|
||||||
= link_to "⇧ home", root_path
|
|
||||||
|
|
||||||
Editing your profile
|
|
||||||
|
|
||||||
|
|
||||||
= f.error_messages
|
= f.error_messages
|
||||||
|
|
||||||
|
|
@ -16,11 +16,11 @@
|
||||||
= p.hidden_field :image_url, :value => @profile.image_url, :id => 'image_url_field'
|
= p.hidden_field :image_url, :value => @profile.image_url, :id => 'image_url_field'
|
||||||
- for photo in @photos
|
- for photo in @photos
|
||||||
- if photo.url(:thumb_medium) == @profile.image_url
|
- if photo.url(:thumb_medium) == @profile.image_url
|
||||||
%div.small_photo{:id => photo.image.thumb_medium.url, :class=>'selected'}
|
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
||||||
= check_box_tag 'checked_photo', true, true
|
= check_box_tag 'checked_photo', true, true
|
||||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||||
- else
|
- else
|
||||||
%div.small_photo{:id => photo.image.thumb_medium.url}
|
%div.small_photo{:id => photo.url(:thumb_medium)}
|
||||||
= check_box_tag 'checked_photo'
|
= check_box_tag 'checked_photo'
|
||||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||||
=will_paginate @photos
|
=will_paginate @photos
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,42 @@
|
||||||
- title "Users"
|
%h1.big_text
|
||||||
|
.back
|
||||||
|
= link_to "⇧ home", root_path
|
||||||
|
|
||||||
|
Search
|
||||||
|
|
||||||
|
%p
|
||||||
|
=form_tag '/users', :method => "get" do
|
||||||
|
= text_field_tag :q
|
||||||
|
= submit_tag "search"
|
||||||
|
= link_to "reset", users_path
|
||||||
|
|
||||||
|
= (@people.count).to_s + search_or_index
|
||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
%th Real Name
|
%th real name
|
||||||
%th email
|
%th email
|
||||||
%th Password
|
%th url
|
||||||
- for user in @users
|
- for person in @people
|
||||||
%tr
|
%tr
|
||||||
%td= user.real_name
|
%td= person.real_name
|
||||||
%td= user.email
|
%td= person.email
|
||||||
%td= user.encrypted_password
|
%td= person.url
|
||||||
|
|
||||||
|
-if current_user.friends.include? person
|
||||||
|
|
||||||
|
- elsif person.id == current_user.person.id
|
||||||
|
%td
|
||||||
|
%td thats you!
|
||||||
|
-elsif current_user.pending_requests.find_by_person_id(person.id)
|
||||||
|
%td
|
||||||
|
%td ^-you have a friend request from this person
|
||||||
|
-elsif current_user.pending_requests.find_by_url(person.receive_url)
|
||||||
|
%td
|
||||||
|
%td friend request pending
|
||||||
|
-else
|
||||||
|
%td
|
||||||
|
%td
|
||||||
|
= form_for Request.new do |f|
|
||||||
|
= f.select(:group_id, @groups_array)
|
||||||
|
= f.hidden_field :destination_url, :value => person.email
|
||||||
|
= f.submit "add friend"
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ module Diaspora
|
||||||
# -- all .rb files in that directory are automatically loaded.
|
# -- all .rb files in that directory are automatically loaded.
|
||||||
|
|
||||||
# Add additional load paths for your own custom dirs
|
# Add additional load paths for your own custom dirs
|
||||||
config.autoload_paths += %W(#{config.root}/lib)
|
#config.autoload_paths += %W(#{config.root}/lib)
|
||||||
|
|
||||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||||
# :all can be used as a placeholder for all plugins not explicitly named
|
# :all can be used as a placeholder for all plugins not explicitly named
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Diaspora::Application.routes.draw do |map|
|
Diaspora::Application.routes.draw do
|
||||||
resources :people
|
resources :people
|
||||||
resources :users, :only => [:edit, :show, :update]
|
resources :users, :except => [:create, :new]
|
||||||
resources :status_messages
|
resources :status_messages
|
||||||
resources :comments
|
resources :comments
|
||||||
resources :requests
|
resources :requests
|
||||||
|
|
|
||||||
86
config/selenium.yml
Normal file
86
config/selenium.yml
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
common: &common
|
||||||
|
# Try to kill mongrel after suite if tmp/pids/mongrel_selenium.pid exists
|
||||||
|
# kill_mongrel_after_suite: true
|
||||||
|
|
||||||
|
local: &local
|
||||||
|
<<: *common
|
||||||
|
test_framework: webrat
|
||||||
|
selenium_server_address: "127.0.0.1"
|
||||||
|
selenium_server_port: "4444"
|
||||||
|
selenium_browser_key: "*chrome /Applications/Firefox.app/Contents/MacOS/firefox-bin"
|
||||||
|
application_address: "127.0.0.1"
|
||||||
|
application_port: "4000"
|
||||||
|
|
||||||
|
local_jsunit:
|
||||||
|
<<: *local
|
||||||
|
application_port: "8080"
|
||||||
|
|
||||||
|
# Possible Sauce Labs configurations as of 2009/11/19
|
||||||
|
# From: http://saucelabs.com/products/docs/sauce-ondemand/browsers
|
||||||
|
#
|
||||||
|
# saucelabs_browser_os saucelabs_browser saucelabs_browser_version (pick one)
|
||||||
|
#
|
||||||
|
# "Windows 2003" "iexplore" "6.", "7.", "8."
|
||||||
|
# "firefox" "2.", "3.0", "3.5"
|
||||||
|
# "safari" "3.", "4."
|
||||||
|
# "opera" "9."
|
||||||
|
# "googlechrome" ""
|
||||||
|
# "Linux" "firefox" "3."
|
||||||
|
saucelabs: &saucelabs
|
||||||
|
<<: *common
|
||||||
|
test_framework: webrat
|
||||||
|
# URL of Selenium RC server:
|
||||||
|
selenium_server_address: "saucelabs.com"
|
||||||
|
selenium_server_port: "4444"
|
||||||
|
# Saucelabs credentials / Browser to drive
|
||||||
|
saucelabs_username: "YOUR-SAUCELABS-USERNAME"
|
||||||
|
saucelabs_access_key: "YOUR-SAUCELABS-ACCESS-KEY"
|
||||||
|
saucelabs_browser_os: "Linux"
|
||||||
|
saucelabs_browser: "firefox"
|
||||||
|
saucelabs_browser_version: "3."
|
||||||
|
saucelabs_max_duration_seconds: 1800
|
||||||
|
# Selenium RC browser connects to and tests the app at this URL:
|
||||||
|
application_address: "testhost.com" # this will be ovewritten if tunnel_method == :saucetunnel
|
||||||
|
application_port: 80
|
||||||
|
# App host can actually be a tunnel that tunnels from <application_address>:<application_port> to localhost:<tunnel_to_localhost_port>
|
||||||
|
# There are 3 kinds of tunnels:
|
||||||
|
#
|
||||||
|
# tunnel_method: :saucetunnel
|
||||||
|
# tunnel_to_localhost_port: 4000 # Warning: application_port and tunnel_to_localhost_port must be identical if you are using Webrat
|
||||||
|
# tunnel_startup_timeout: 240
|
||||||
|
#
|
||||||
|
# tunnel_method: :sshtunnel
|
||||||
|
# application_address: proxy.mycompany.com
|
||||||
|
# application_port: 12345 # or can be a range XXXX-YYYY
|
||||||
|
# tunnel_to_localhost_port: 4000 # Warning: application_port and tunnel_to_localhost_port must be identical if you are using Webrat
|
||||||
|
# tunnel_username: fred
|
||||||
|
# tunnel_keyfile: "/Users/<%= ENV['USER'] %>/.ssh/id_rsa" # or tunnel_password: "password"
|
||||||
|
#
|
||||||
|
# tunnel_method: :othertunnel You're managing your tunnel independently
|
||||||
|
|
||||||
|
saucelabs_jsunit: &saucelabs_jsunit
|
||||||
|
<<: *saucelabs
|
||||||
|
# We are using the Jetty server for Saucelabs JsUnit selenium testing.
|
||||||
|
localhost_app_server_port: "8080"
|
||||||
|
|
||||||
|
saucelabs_jsunit_firefox:
|
||||||
|
<<: *saucelabs_jsunit
|
||||||
|
|
||||||
|
saucelabs_jsunit_ie:
|
||||||
|
<<: *saucelabs_jsunit
|
||||||
|
saucelabs_browser_os: "Windows 2003"
|
||||||
|
saucelabs_browser: "iexplore"
|
||||||
|
saucelabs_browser_version: "7."
|
||||||
|
jsunit_polling_interval_seconds: 300
|
||||||
|
|
||||||
|
saucelabs_jsunit_safari:
|
||||||
|
<<: *saucelabs_jsunit
|
||||||
|
saucelabs_browser_os: "Windows 2003"
|
||||||
|
saucelabs_browser: "safari"
|
||||||
|
saucelabs_browser_version: "4."
|
||||||
|
|
||||||
|
saucelabs_jsunit_chrome:
|
||||||
|
<<: *saucelabs_jsunit
|
||||||
|
saucelabs_browser_os: "Windows 2003"
|
||||||
|
saucelabs_browser: "googlechrome"
|
||||||
|
saucelabs_browser_version: ""
|
||||||
|
|
@ -3,21 +3,21 @@ require 'config/environment'
|
||||||
remote_url = "http://tom.joindiaspora.com/"
|
remote_url = "http://tom.joindiaspora.com/"
|
||||||
remote_url = "http://localhost:3000/"
|
remote_url = "http://localhost:3000/"
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.create!( :email => "tom@tom.joindiaspora.com",
|
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||||
:password => "evankorth",
|
:password => "evankorth",
|
||||||
:person => Person.new(
|
:person => {
|
||||||
:email => "tom@tom.joindiaspora.com",
|
:email => "tom@tom.joindiaspora.com",
|
||||||
:url => remote_url,
|
:url => remote_url,
|
||||||
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
:profile => { :first_name => "Alexander", :last_name => "Hamiltom" }}
|
||||||
)
|
)
|
||||||
user.person.save!
|
user.person.save!
|
||||||
|
|
||||||
user2 = User.create!( :email => "korth@tom.joindiaspora.com",
|
user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
|
||||||
:password => "evankorth",
|
:password => "evankorth",
|
||||||
:person => Person.new( :email => "korth@tom.joindiaspora.com",
|
:person => { :email => "korth@tom.joindiaspora.com",
|
||||||
:url => remote_url,
|
:url => remote_url,
|
||||||
:profile => Profile.new( :first_name => "Evan",
|
:profile => { :first_name => "Evan",
|
||||||
:last_name => "Korth")))
|
:last_name => "Korth"}})
|
||||||
|
|
||||||
user2.person.save!
|
user2.person.save!
|
||||||
|
|
||||||
|
|
|
||||||
53
lib/tasks/saucelabs_adapter.rake
Normal file
53
lib/tasks/saucelabs_adapter.rake
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
require 'saucelabs_adapter/run_utils'
|
||||||
|
|
||||||
|
class Rake::Task
|
||||||
|
def self.exists?(name)
|
||||||
|
tasks.any? { |t| t.name == name }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace :selenium do
|
||||||
|
|
||||||
|
# Rake tasks are cumulative, and some old plugins are still defining selenium:server, so clear it.
|
||||||
|
Rake::Task[:'selenium:server'].clear_actions if Rake::Task.exists?('selenium:server')
|
||||||
|
|
||||||
|
desc "Run the selenium remote-control server"
|
||||||
|
task :server do
|
||||||
|
system('bundle exec selenium-rc')
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Run the selenium remote-control server in the background"
|
||||||
|
task :server_bg do
|
||||||
|
system('nohup selenium-rc 2&>1 &')
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Runs Selenium tests locally (selenium server must already be started)"
|
||||||
|
task :local => [:local_env, :suite]
|
||||||
|
|
||||||
|
desc "Run Selenium tests at saucelabs.com (using configuration 'saucelabs' in config/selenium.yml)"
|
||||||
|
task :sauce => [:sauce_env, :suite]
|
||||||
|
|
||||||
|
desc "Run Selenium tests using configuration SELENIUM_ENV (from config/selenium.yml)"
|
||||||
|
task :custom => [:check_selenium_env_is_set, :suite]
|
||||||
|
|
||||||
|
task :local_env do
|
||||||
|
ENV['SELENIUM_ENV'] = 'local'
|
||||||
|
end
|
||||||
|
|
||||||
|
task :sauce_env do
|
||||||
|
ENV['SELENIUM_ENV'] = 'saucelabs'
|
||||||
|
end
|
||||||
|
|
||||||
|
task :check_selenium_env_is_set do
|
||||||
|
raise "SELENIUM_ENV must be set" unless ENV['SELENIUM_ENV']
|
||||||
|
end
|
||||||
|
|
||||||
|
task :suite do
|
||||||
|
if (File.exists?("test/selenium/selenium_suite.rb"))
|
||||||
|
RunUtils.run "ruby test/selenium/selenium_suite.rb"
|
||||||
|
else
|
||||||
|
puts "test/selenium/selenium_suite.rb not found, bailing.\nPlease create a script that will run your selenium tests."
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
7
test/selenium/sample_webrat_test.rb
Normal file
7
test/selenium/sample_webrat_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
class SampleWebratTest < ActionController::IntegrationTest
|
||||||
|
|
||||||
|
def test_widget
|
||||||
|
visit "/"
|
||||||
|
assert_contain "sign in"
|
||||||
|
end
|
||||||
|
end
|
||||||
11
test/selenium/selenium_suite.rb
Normal file
11
test/selenium/selenium_suite.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
||||||
|
require 'test/unit/ui/console/testrunner'
|
||||||
|
require 'webrat'
|
||||||
|
require 'saucelabs_adapter'
|
||||||
|
|
||||||
|
Webrat.configure do |config|
|
||||||
|
config.mode = :selenium
|
||||||
|
config.application_framework = :rack
|
||||||
|
end
|
||||||
|
|
||||||
|
require File.join(File.dirname(__FILE__), 'sample_webrat_test')
|
||||||
|
|
@ -7,7 +7,7 @@ class ActiveSupport::TestCase
|
||||||
#
|
#
|
||||||
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
||||||
# -- they do not yet inherit this setting
|
# -- they do not yet inherit this setting
|
||||||
fixtures :all
|
#fixtures :all
|
||||||
|
|
||||||
# Add more helper methods to be used by all tests here...
|
# Add more helper methods to be used by all tests here...
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue