From d054162bbeaa21f80a0141e166f847e3772c6749 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 18 Aug 2010 20:51:55 -0700 Subject: [PATCH 01/27] more RC updating stuff --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index e8d5616f0..38c31c879 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ -Diaspora::Application.routes.draw do |map| +Diaspora::Application.routes.draw do resources :people resources :users, :only => [:edit, :show, :update] resources :status_messages From 284601c6b1e4e8df7dfd76708a14441905ecd4cb Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 20:59:01 -0700 Subject: [PATCH 02/27] got moved photo.image.stuff to photo.url[:stuff] --- app/helpers/photos_helper.rb | 2 +- app/views/users/edit.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index b9231fe94..c518ceec5 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -1,7 +1,7 @@ module PhotosHelper 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 def link_to_prev(photo, album) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 24aa8e7f0..670739246 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -16,11 +16,11 @@ = p.hidden_field :image_url, :value => @profile.image_url, :id => 'image_url_field' - for photo in @photos - 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 = link_to image_tag(photo.url(:thumb_medium)), "#" - else - %div.small_photo{:id => photo.image.thumb_medium.url} + %div.small_photo{:id => photo.url(:thumb_medium)} = check_box_tag 'checked_photo' = link_to image_tag(photo.url(:thumb_medium)), "#" =will_paginate @photos From a23df47dbc119aa586788e30d7ee50cfdd44877e Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 18 Aug 2010 21:10:42 -0700 Subject: [PATCH 04/27] Trying to merge in the pivots changes that we want in master --- app/controllers/application_controller.rb | 1 - app/controllers/users_controller.rb | 14 ------- app/models/user.rb | 20 ++++------ app/views/devise/confirmations/new.html.haml | 3 +- app/views/devise/passwords/edit.html.haml | 3 +- app/views/devise/passwords/new.html.haml | 3 +- app/views/devise/registrations/edit.html.haml | 3 +- app/views/devise/registrations/new.html.haml | 2 +- app/views/devise/sessions/new.html.haml | 6 ++- app/views/devise/unlocks/new.html.haml | 3 +- app/views/groups/index.html.haml | 2 +- config/routes.rb | 8 ++-- config/sprinkle/packages/server.rb | 37 +----------------- config/sprinkle/provision.rb | 39 +------------------ spec/controllers/people_controller_spec.rb | 5 ++- spec/models/user_spec.rb | 16 -------- 16 files changed, 36 insertions(+), 129 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 291246750..f173633c4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,6 @@ class ApplicationController < ActionController::Base protect_from_forgery :except => :receive - layout 'application' before_filter :set_friends_and_status, :count_requests diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 69b728755..5d407e724 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -23,19 +23,5 @@ class UsersController < ApplicationController end end - def create - @user = User.instantiate(params[:user]) - - if @user.created_at && @user.person.created_at - flash[:notice] = "Successfully signed up." - redirect_to root_path - else - render :action => 'new' - end - end - - def new - @user = User.new - end end diff --git a/app/models/user.rb b/app/models/user.rb index 3b269f135..56f7882d1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,8 +16,7 @@ class User many :groups, :class_name => 'Group' - before_validation_on_create :assign_key - before_validation :do_bad_things + after_validation_on_create :setup_person ######## Making things work ######## key :email, String @@ -297,12 +296,6 @@ class User ###Helpers############ - def self.instantiate( opts = {} ) - opts[:person][:email] = opts[:email] - opts[:person][:serialized_key] = generate_key - User.create( opts) - end - def terse_url terse= self.url.gsub(/https?:\/\//, '') terse.gsub!(/www\./, '') @@ -310,10 +303,6 @@ class User terse end - def do_bad_things - self.password_confirmation = self.password - end - def visible_person_by_id( id ) id = ensure_bson id return self.person if id == self.person.id @@ -329,6 +318,13 @@ class User id = ensure_bson person.id groups.select {|group| group.person_ids.include? id} end + + def setup_person + self.person.serialized_key ||= generate_key.export + self.person.email = email + self.person.save! + end + protected def assign_key diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index 2c49b859a..548a024bc 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -5,5 +5,6 @@ = f.label :email %br/ = f.text_field :email - %p= f.submit "Resend confirmation instructions" + %p + = f.submit "Resend confirmation instructions" = render :partial => "devise/shared/links" diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index 543d47e55..025c214b0 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -10,5 +10,6 @@ = f.label :password_confirmation %br/ = f.password_field :password_confirmation - %p= f.submit "Change my password" + %p + = f.submit "Change my password" = render :partial => "devise/shared/links" diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index d1176b8c6..9afd3d244 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -5,5 +5,6 @@ = f.label :email %br/ = f.text_field :email - %p= f.submit "Send me reset password instructions" + %p + = f.submit "Send me reset password instructions" = render :partial => "devise/shared/links" diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index d252d9af4..dfbe2a35a 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -20,7 +20,8 @@ %i (we need your current password to confirm your changes) %br/ = f.password_field :current_password - %p= f.submit "Update" + %p + = f.submit "Update" %h3 Cancel my account %p Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}. diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 7491611f3..dd50d306a 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -14,7 +14,7 @@ = f.password_field :password_confirmation = f.fields_for :person do |p| - = p.hidden_field :url, :value => request.path + = p.hidden_field :url, :value => request.host = p.fields_for :profile do |pr| %p diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index a36917c7b..daa7e6030 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,13 +1,15 @@ = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %p + = f.label :email = f.text_field :email - %br + %p + = f.label :password = f.password_field :password /%p /- if devise_mapping.rememberable? / = f.check_box :remember_me / = f.label :remember_me + = f.submit "Sign in" %p - = f.submit "Sign in" = render :partial => "devise/shared/links" diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index a73b9caa5..24b7eb862 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -5,5 +5,6 @@ = f.label :email %br/ = f.text_field :email - %p= f.submit "Resend unlock instructions" + %p + = f.submit "Resend unlock instructions" = render :partial => "devise/shared/links" diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index 6d8389727..89ef12f84 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -1,5 +1,5 @@ %h1 - welcome home, + welcome, = current_user.profile.first_name - @group.nil? ? group_id = nil : group_id = @group.id diff --git a/config/routes.rb b/config/routes.rb index e8d5616f0..b0e12b30b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,10 +15,10 @@ Diaspora::Application.routes.draw do |map| #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file - devise_for :users, :path_names => {:sign_up => "get_to_the_choppa", :sign_in => "login", :sign_out => "logout"} - match 'login', :to => 'devise/sessions#new', :as => "new_user_session" - match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" - match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration" + devise_for :users + match 'login', :to => 'devise/sessions#new', :as => "new_user_session" + match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" + match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration" #public routes # diff --git a/config/sprinkle/packages/server.rb b/config/sprinkle/packages/server.rb index 99f326c8b..c553707b3 100644 --- a/config/sprinkle/packages/server.rb +++ b/config/sprinkle/packages/server.rb @@ -1,16 +1,15 @@ -package :nginx do +package :nginx, :provides=> :webserver do description 'Nginx HTTP server' version '0.7.67' source "http://nginx.org/download/nginx-#{version}.tar.gz" requires :nginx_dependencies end -package :nginx_conf, :provides=> :webserver do +package :nginx_conf do description 'Nginx conf file' transfer "#{File.dirname(__FILE__)}/../conf/nginx.conf", '/usr/local/conf/nginx.conf', :render => true do pre :install, "mkdir -p /usr/local/sbin/conf/" end - requires :nginx end package :nginx_dependencies do @@ -18,35 +17,3 @@ package :nginx_dependencies do apt %w( libc6 libpcre3 libpcre3-dev libssl0.9.8) source "http://zlib.net/zlib-1.2.5.tar.gz" end - -=begin -package :mongrel do - description 'Mongrel Application Server' - gem 'mongrel' - version '1.1.5' -end - -package :mongrel_cluster, :provides => :appserver do - description 'Cluster Management for Mongrel' - gem 'mongrel_cluster' - version '1.0.5' - requires :mongrel -end - -package :apache, :provides => :webserver do - description 'Apache 2 HTTP Server' - version '2.2.15' - - source "http://download.nextag.com/apache/httpd/httpd-#{version}.tar.bz2" do - enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so ) - prefix "/opt/local/apache2-#{version}" - post :install, 'install -m 755 support/apachectl /etc/init.d/apache2', 'update-rc.d -f apache2 defaults' - end - requires :apache_dependencies -end - -package :apache_dependencies do - description 'Apache 2 HTTP Server Build Dependencies' - apt %w( openssl libtool mawk zlib1g-dev libssl-dev ) -end -=end diff --git a/config/sprinkle/provision.rb b/config/sprinkle/provision.rb index 63302b874..e085a2602 100644 --- a/config/sprinkle/provision.rb +++ b/config/sprinkle/provision.rb @@ -1,39 +1,13 @@ #!/usr/bin/env sprinkle -s -# Annotated Example Sprinkle Rails deployment script -# -# This is an example Sprinkle script configured to install Rails from gems, Apache, Ruby, -# Sphinx and Git from source, and mysql and Git dependencies from apt on an Ubuntu system. -# -# Installation is configured to run via capistrano (and an accompanying deploy.rb recipe script). -# Source based packages are downloaded and built into /usr/local on the remote system. -# -# A sprinkle script is separated into 3 different sections. Packages, policies and deployment: - - -# Packages (separate files for brevity) -# -# Defines the world of packages as we know it. Each package has a name and -# set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have -# relationships to each other via dependencies. require "#{File.dirname(__FILE__)}/packages/essential" require "#{File.dirname(__FILE__)}/packages/database" require "#{File.dirname(__FILE__)}/packages/server" require "#{File.dirname(__FILE__)}/packages/scm" require "#{File.dirname(__FILE__)}/packages/ruby" -#require "#{File.dirname(__FILE__)}/packages/unfortunately_essential" -# Policies -# -# Names a group of packages (optionally with versions) that apply to a particular set of roles: -# -# Associates the rails policy to the application servers. Contains rails, and surrounding -# packages. Note, appserver, database, webserver and search are all virtual packages defined above. -# If there's only one implementation of a virtual package, it's selected automatically, otherwise -# the user is requested to select which one to use. - -policy :diaspora, :roles => [:tom, :backer] do +policy :diaspora, :roles => [:tom,:backer] do # requires :clean_dreamhost requires :tools requires :rubygems @@ -43,16 +17,9 @@ policy :diaspora, :roles => [:tom, :backer] do requires :webserver requires :scm requires :vim + requires :nginx_conf end -# Deployment -# -# Defines script wide settings such as a delivery mechanism for executing commands on the target -# system (eg. capistrano), and installer defaults (eg. build locations, etc): -# -# Configures spinkle to use capistrano for delivery of commands to the remote machines (via -# the named 'deploy' recipe). Also configures 'source' installer defaults to put package gear -# in /usr/local deployment do @@ -73,5 +40,3 @@ deployment do end end -# End of script, given the above information, Spinkle will apply the defined policy on all roles using the -# deployment settings specified. diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index f448f9f36..f039e0101 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -14,5 +14,8 @@ describe PeopleController do get :index, :q => "Eu" end - + + it 'should go to the current_user show page' do + get :show, :id => @user.person.id + end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 146547edb..548966548 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -6,20 +6,6 @@ describe User do @group = @user.group(:name => 'heroes') end - it 'should instantiate with a person and be valid' do - user = User.instantiate(:email => "bob@bob.com", - :password => "password", - :password_confirmation => "password", - :person => - {:profile => { - :first_name => "bob", - :last_name => "grimm"}}) - - user.save.should be true - user.person.should_not be nil - user.person.profile.should_not be nil - end - describe 'profiles' do it 'should be able to update their profile and send it to their friends' do Factory.create(:person) @@ -32,6 +18,4 @@ describe User do @user.profile.image_url.should == "http://clown.com" end end - - end From a26543b4a51f4adb42d531440c7475f9c733e16b Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 18 Aug 2010 21:22:49 -0700 Subject: [PATCH 06/27] rolling back --- Gemfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index f2b895e32..660c818b0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,9 @@ source 'http://rubygems.org' -gem 'rails', '3.0.0.rc' -gem 'bundler', '1.0.0.rc.5' -#gem 'rails', '3.0.0.beta4' -#gem 'bundler', '0.9.26' +#gem 'rails', '3.0.0.rc' +#gem 'bundler', '1.0.0.rc.5' +gem 'rails', '3.0.0.beta4' +gem 'bundler', '0.9.26' #Security gem 'devise', :git => 'http://github.com/BadMinus/devise.git' From ff412770889707ab46b1e7594e7c7312457aa262 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 18 Aug 2010 21:34:02 -0700 Subject: [PATCH 08/27] one thing beta couldnt handle --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 206139b5e..bbceb6f94 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,7 +15,7 @@ module Diaspora # -- all .rb files in that directory are automatically loaded. # 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). # :all can be used as a placeholder for all plugins not explicitly named From 0c9f041f28b57d1f0259521a294f0c65f4dd24ec Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 21:42:37 -0700 Subject: [PATCH 09/27] we need do bad things in the user for seeding the database --- app/models/user.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 56f7882d1..b9b03dede 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,6 +16,7 @@ class User many :groups, :class_name => 'Group' + before_validation :do_bad_things after_validation_on_create :setup_person ######## Making things work ######## @@ -302,7 +303,11 @@ class User terse = terse.chop! if terse[-1, 1] == '/' terse end - + + def do_bad_things + self.password_confirmation = self.password + end + def visible_person_by_id( id ) id = ensure_bson id return self.person if id == self.person.id From 0f6ec71dcd37fbc0ec170dba258ffad2a08f9fad Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 21:45:41 -0700 Subject: [PATCH 10/27] we need assign key as well --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user.rb b/app/models/user.rb index b9b03dede..7f4ea5c98 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,6 +16,7 @@ class User many :groups, :class_name => 'Group' + before_validation_on_create :assign_key before_validation :do_bad_things after_validation_on_create :setup_person From 0a3277d3069df0228019d9abf33b761ced24a67d Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 21:51:51 -0700 Subject: [PATCH 11/27] maybe the instantiate method will help --- app/models/user.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 7f4ea5c98..9c88b8462 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -297,7 +297,12 @@ class User end ###Helpers############ - + def self.instantiate( opts = {} ) + opts[:person][:email] = opts[:email] + opts[:person][:serialized_key] = generate_key + User.create( opts) + end + def terse_url terse= self.url.gsub(/https?:\/\//, '') terse.gsub!(/www\./, '') From 9e78c9b64c686df1f066b59f16113c0aadb88a69 Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 21:58:29 -0700 Subject: [PATCH 12/27] removing setup person --- app/models/user.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 9c88b8462..a8f7c3c52 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,7 +18,6 @@ class User before_validation_on_create :assign_key before_validation :do_bad_things - after_validation_on_create :setup_person ######## Making things work ######## key :email, String From 84cc59801742c5e8fa303a99f9dc6a184280b834 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 18 Aug 2010 22:58:57 -0700 Subject: [PATCH 13/27] MS a couple of small bug fixes when updateing user profile....starting to attept friend index/search page --- app/controllers/requests_controller.rb | 1 + app/controllers/users_controller.rb | 13 +++++++++++-- app/helpers/people_helper.rb | 11 +++++++++++ app/helpers/requests_helper.rb | 1 + app/views/people/index.html.haml | 14 +++++++------- app/views/users/index.html.haml | 23 +++++++++++++++-------- config/routes.rb | 2 +- 7 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 app/helpers/people_helper.rb diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index ae274c142..b6b3dc822 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -31,6 +31,7 @@ class RequestsController < ApplicationController end def create + puts params.inspect rel_hash = relationship_flow(params[:request][:destination_url]) Rails.logger.debug("Sending request: #{rel_hash}") @request = current_user.send_request(rel_hash, params[:request][:group]) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5d407e724..10db48c04 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,13 @@ class UsersController < ApplicationController before_filter :authenticate_user!, :except => [:new, :create] + def index + unless params[:q] + @people = Person.all + render :index + else + @people = Person.search(params[:q]) + end + end def show @user= User.first(:id => params[:id]) @@ -16,12 +24,13 @@ class UsersController < ApplicationController @user = User.where(:id => params[:id]).first if @user.update_profile(params[:user]) - flash[:notice] = "Successfully updated user." - redirect_to @user + flash[:notice] = "Successfully updated your profile" + redirect_to @user.person else render :action => 'edit' end end + end diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb new file mode 100644 index 000000000..60c971f47 --- /dev/null +++ b/app/helpers/people_helper.rb @@ -0,0 +1,11 @@ +module PeopleHelper + + def search_or_index + if params[:q] + " results for #{q}" + else + " people on this pod" + end + + end +end \ No newline at end of file diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index 37a5485c4..c0320c0b8 100644 --- a/app/helpers/requests_helper.rb +++ b/app/helpers/requests_helper.rb @@ -29,6 +29,7 @@ module RequestsHelper action = :none url = nil local_person = Person.by_webfinger identifier + puts local_person.inspect if local_person action = (local_person == current_user.person ? :none : :friend) url = local_person.receive_url diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml index cfc12dcc9..8b7b488ec 100644 --- a/app/views/people/index.html.haml +++ b/app/views/people/index.html.haml @@ -1,10 +1,10 @@ -%h1.big_text - .back - = link_to '⇧ home', root_path - Friends - .button.right - = link_to 'Add Friend', requests_path - +/ %h1.big_text +/ .back +/ = link_to '⇧ home', root_path +/ Friends +/ .button.right +/ = link_to 'Add Friend', requests_path += @people.count.to_s + search_or_index %table %tr %th real name diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 6f210359c..6975a8054 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -1,12 +1,19 @@ -- title "Users" - += @people.count.to_s + search_or_index %table %tr - %th Real Name + %th real name %th email - %th Password - - for user in @users + %th url + - for person in @people %tr - %td= user.real_name - %td= user.email - %td= user.encrypted_password + %td= person.real_name + %td= person.email + %td= person.url + %td + %select{ :class => "group_selector", :style=>"display:inline;"} + %option Add to group + %option + - for group in current_user.groups + %option{:value => group.id}= group.name + + %td= link_to "add as friend", requests_path(:request => {:destination_url => person.email}), :class => "submit", :method => "post" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 84260a456..3e58008fe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Diaspora::Application.routes.draw do resources :people - resources :users, :only => [:edit, :show, :update] + resources :users #, :only => [:edit, :show, :update] resources :status_messages resources :comments resources :requests From af8448dd512ec665fb45b141845905308dec855a Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 19 Aug 2010 10:20:43 -0700 Subject: [PATCH 14/27] photos on the profile edit page now are only your photos, for now. also, no more remove friend button on your profile page --- app/controllers/users_controller.rb | 8 +++----- app/views/people/show.html.haml | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 10db48c04..c93c474fc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -16,8 +16,9 @@ class UsersController < ApplicationController def edit @user = User.first(:id => params[:id]) + @person = @user.person @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 def update @@ -30,7 +31,4 @@ class UsersController < ApplicationController render :action => 'edit' end end - - - -end +end diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index af8eb86ab..39c60ec7e 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -5,7 +5,8 @@ %h1 = @person.real_name - - unless @person.id == current_user.id + - unless @person.id == current_user.person.id + .right = link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete, :class => "button" From 9b47e67a15ff293ab921d0d055d489aa185959e4 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 19 Aug 2010 10:23:40 -0700 Subject: [PATCH 15/27] call the right method in before_validation_on_create --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index a8f7c3c52..1c0bf1b97 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,7 +16,7 @@ class User many :groups, :class_name => 'Group' - before_validation_on_create :assign_key + before_validation_on_create :setup_person before_validation :do_bad_things ######## Making things work ######## @@ -330,7 +330,7 @@ class User end def setup_person - self.person.serialized_key ||= generate_key.export + assign_key self.person.email = email self.person.save! end From e277244614f43dd7e374d162fb7a48ccd56a806a Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 19 Aug 2010 10:38:42 -0700 Subject: [PATCH 16/27] Fixing users routes --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 3e58008fe..946d34729 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Diaspora::Application.routes.draw do resources :people - resources :users #, :only => [:edit, :show, :update] + resources :users, :except => [:create, :new] resources :status_messages resources :comments resources :requests From 5d25861dc6785c1bfc5b01d39e2d5088e1179b53 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 19 Aug 2010 10:46:47 -0700 Subject: [PATCH 17/27] IZ MS person profile page now displays only posts a user can see --- app/controllers/people_controller.rb | 6 ++++-- app/models/post.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 28b5de57d..4019b871c 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -14,8 +14,10 @@ class PeopleController < ApplicationController def show @person = current_user.visible_person_by_id(params[:id]) @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 end diff --git a/app/models/post.rb b/app/models/post.rb index e1821d615..8f30586a0 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -31,7 +31,7 @@ class Post #Querying def self.newest_for(person) - self.first(:person_id => person.id, :order => '_id desc') + self.where(:person_id => person.id, :order => '_id desc') end #ENCRYPTION From 54afb1bad4cc3fbcbc561cc56736509426eaa905 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 19 Aug 2010 10:49:04 -0700 Subject: [PATCH 18/27] Rolling assign_key into setup_person --- app/models/user.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 1c0bf1b97..f7bf1b6eb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -330,17 +330,13 @@ class User end def setup_person - assign_key + self.person.serialized_key = generate_key.export self.person.email = email self.person.save! end protected - def assign_key - self.person.serialized_key ||= generate_key.export - end - def generate_key OpenSSL::PKey::RSA::generate 1024 end From df435dc3190c3b62b0d9c84547bc1b9892e9ca1f Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 19 Aug 2010 11:59:58 -0700 Subject: [PATCH 19/27] MS IZ made a reques form in the user index page --- app/controllers/requests_controller.rb | 2 +- app/controllers/users_controller.rb | 3 +++ app/models/group.rb | 5 +++- app/views/requests/_new_request.haml | 2 +- app/views/users/index.html.haml | 33 ++++++++++++++++---------- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index b6b3dc822..24c4634b8 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -34,7 +34,7 @@ class RequestsController < ApplicationController puts params.inspect rel_hash = relationship_flow(params[:request][:destination_url]) 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 flash[:notice] = "a friend request was sent to #{@request.destination_url}" diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c93c474fc..133de0610 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,9 @@ class UsersController < ApplicationController before_filter :authenticate_user!, :except => [:new, :create] def index + + @group_array = current_user.groups.collect{|x| [x.to_s, x.id]} + unless params[:q] @people = Person.all render :index diff --git a/app/models/group.rb b/app/models/group.rb index 275bbf3a5..a01dcca5f 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -15,6 +15,9 @@ class Group belongs_to :user, :class_name => 'User' timestamps! - + + def to_s + name + end end diff --git a/app/views/requests/_new_request.haml b/app/views/requests/_new_request.haml index 42cd8b5e5..5dbe3b203 100644 --- a/app/views/requests/_new_request.haml +++ b/app/views/requests/_new_request.haml @@ -7,6 +7,6 @@ Enter a Diaspora URL, Diaspora username, or random email address: = f.text_field :destination_url - = f.hidden_field :group, :value => @group.id + = f.hidden_field :group_id, :value => @group.id = f.submit diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 6975a8054..fec427aa4 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -1,19 +1,26 @@ -= @people.count.to_s + search_or_index += (@people.count-1).to_s + search_or_index %table %tr %th real name %th email %th url - for person in @people - %tr - %td= person.real_name - %td= person.email - %td= person.url - %td - %select{ :class => "group_selector", :style=>"display:inline;"} - %option Add to group - %option - - for group in current_user.groups - %option{:value => group.id}= group.name - - %td= link_to "add as friend", requests_path(:request => {:destination_url => person.email}), :class => "submit", :method => "post" \ No newline at end of file + - unless person.id == current_user.person.id + %tr + %td= person.real_name + %td= person.email + %td= person.url + + -if current_user.friends.include? person + -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 + = form_for Request.new do |f| + =f.select(:group_id, @groups_array) + = f.hidden_field :destination_url, :value => person.email + =f.submit From c98c52ad14ba5b15897bee8f18a38ae9355a020f Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 19 Aug 2010 12:17:29 -0700 Subject: [PATCH 20/27] MS IZ renamed the array --- app/controllers/users_controller.rb | 2 +- app/views/users/index.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 133de0610..73e92d385 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,7 +2,7 @@ class UsersController < ApplicationController before_filter :authenticate_user!, :except => [:new, :create] def index - @group_array = current_user.groups.collect{|x| [x.to_s, x.id]} + @groups_array = current_user.groups.collect{|x| [x.to_s, x.id]} unless params[:q] @people = Person.all diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index fec427aa4..3f0d01435 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -21,6 +21,6 @@ -else %td = form_for Request.new do |f| - =f.select(:group_id, @groups_array) + = f.select(:group_id, @groups_array) = f.hidden_field :destination_url, :value => person.email - =f.submit + = f.submit From 756278f49833424e44fa9089e728edfce09840e0 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 19 Aug 2010 12:37:34 -0700 Subject: [PATCH 21/27] MS added friend search, and allow for autodiscover --- app/controllers/users_controller.rb | 4 +++- app/helpers/people_helper.rb | 4 ++-- app/views/layouts/application.html.haml | 1 + app/views/users/index.html.haml | 16 +++++++++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 73e92d385..3596c26ed 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,9 +1,11 @@ class UsersController < ApplicationController before_filter :authenticate_user!, :except => [:new, :create] + def index - + puts "awesome" @groups_array = current_user.groups.collect{|x| [x.to_s, x.id]} + puts params.inspect unless params[:q] @people = Person.all render :index diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index 60c971f47..fd9ff371c 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -2,10 +2,10 @@ module PeopleHelper def search_or_index if params[:q] - " results for #{q}" + " results for #{params[:q]}" else " people on this pod" end end -end \ No newline at end of file +end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 006872e5b..da2b73eb8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -38,6 +38,7 @@ %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 "settings", edit_user_path(current_user) + %li= link_to "search", users_path %li= link_to "logout", destroy_user_session_path - else = link_to "login", new_user_session_path diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 3f0d01435..9eee6b7d1 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -1,17 +1,26 @@ -= (@people.count-1).to_s + search_or_index +%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 %tr %th real name %th email %th url - - for person in @people - - unless person.id == current_user.person.id + - for person in @people %tr %td= person.real_name %td= person.email %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 @@ -19,6 +28,7 @@ %td %td friend request pending -else + %td %td = form_for Request.new do |f| = f.select(:group_id, @groups_array) From 35f685638024294cf779ee21f493894de34e0f60 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 19 Aug 2010 12:40:50 -0700 Subject: [PATCH 22/27] MS search and index works --- app/controllers/users_controller.rb | 2 -- app/views/users/index.html.haml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3596c26ed..c7e2979b1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,10 +2,8 @@ class UsersController < ApplicationController before_filter :authenticate_user!, :except => [:new, :create] def index - puts "awesome" @groups_array = current_user.groups.collect{|x| [x.to_s, x.id]} - puts params.inspect unless params[:q] @people = Person.all render :index diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 9eee6b7d1..3f14d8ce3 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -33,4 +33,4 @@ = form_for Request.new do |f| = f.select(:group_id, @groups_array) = f.hidden_field :destination_url, :value => person.email - = f.submit + = f.submit "add friend" From 36b2445a1135d1f442d0e9e6147fbfe34264fb7e Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 19 Aug 2010 13:41:48 -0700 Subject: [PATCH 23/27] added title to search page --- app/views/users/edit.html.haml | 12 ++++++------ app/views/users/index.html.haml | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 670739246..e4c884d83 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -1,11 +1,11 @@ +%h1.big_text + .back + = link_to "⇧ home", root_path + + Editing your profile + = form_for @user do |f| - %h1.big_text - .back - = link_to "⇧ home", root_path - - Editing your profile - = f.error_messages diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 3f14d8ce3..bbd50ddd0 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -1,3 +1,9 @@ +%h1.big_text + .back + = link_to "⇧ home", root_path + + Search + %p =form_tag '/users', :method => "get" do = text_field_tag :q From f7608f6292102d75d7615efb204e1a27d44129ce Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 19 Aug 2010 14:12:52 -0700 Subject: [PATCH 24/27] RS IZ trying to create user through instantiate in seed script --- app/models/user.rb | 4 ++-- db/seeds/tom.rb | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index f7bf1b6eb..c26e02f1c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -296,10 +296,10 @@ class User end ###Helpers############ - def self.instantiate( opts = {} ) + def self.instantiate!( opts = {} ) opts[:person][:email] = opts[:email] opts[:person][:serialized_key] = generate_key - User.create( opts) + User.create!( opts) end def terse_url diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index c8b1d41a6..3fdde03be 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -2,21 +2,21 @@ require 'config/environment' remote_url = "http://tom.joindiaspora.com/" # Create seed user -user = User.create!( :email => "tom@tom.joindiaspora.com", +user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :password => "evankorth", - :person => Person.new( + :person => { :email => "tom@tom.joindiaspora.com", :url => remote_url, - :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) + :profile => { :first_name => "Alexander", :last_name => "Hamiltom" }} ) user.person.save! -user2 = User.create!( :email => "korth@tom.joindiaspora.com", +user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", :password => "evankorth", - :person => Person.new( :email => "korth@tom.joindiaspora.com", + :person => { :email => "korth@tom.joindiaspora.com", :url => remote_url, - :profile => Profile.new( :first_name => "Evan", - :last_name => "Korth"))) + :profile => { :first_name => "Evan", + :last_name => "Korth"}}) user2.person.save! From 542c1769f9f796c085a4d063da29a8d156a55f34 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 19 Aug 2010 14:25:34 -0700 Subject: [PATCH 25/27] doing a sanity check, that not requiring serialized key passes the validation --- app/models/person.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/person.rb b/app/models/person.rb index 32d68cab8..7b989ce63 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -27,7 +27,7 @@ class Person before_destroy :remove_all_traces before_validation :clean_url - validates_presence_of :email, :url, :profile, :serialized_key + validates_presence_of :email, :url, :profile#, :serialized_key validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix From 7eb1bb5a009a27f1a5a67d17c735e345c8cd7138 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 19 Aug 2010 14:36:15 -0700 Subject: [PATCH 26/27] removing the sanity check --- app/models/person.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/person.rb b/app/models/person.rb index 7b989ce63..32d68cab8 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -27,7 +27,7 @@ class Person before_destroy :remove_all_traces before_validation :clean_url - validates_presence_of :email, :url, :profile#, :serialized_key + validates_presence_of :email, :url, :profile, :serialized_key validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix From 20678060e72c536ec13a0edfb448e22afcc8cf70 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 19 Aug 2010 15:44:23 -0700 Subject: [PATCH 27/27] selenium, ymls, a sample test --- .gitignore | 1 + Gemfile | 5 +- config/selenium.yml | 86 +++++++++++++++++++++++++++++ lib/tasks/saucelabs_adapter.rake | 53 ++++++++++++++++++ test/selenium/sample_webrat_test.rb | 7 +++ test/selenium/selenium_suite.rb | 11 ++++ test/test_helper.rb | 2 +- 7 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 config/selenium.yml create mode 100644 lib/tasks/saucelabs_adapter.rake create mode 100644 test/selenium/sample_webrat_test.rb create mode 100644 test/selenium/selenium_suite.rb diff --git a/.gitignore b/.gitignore index 721b1f830..dafc5e44d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +*.swap *.swp *.swo *~ diff --git a/Gemfile b/Gemfile index 660c818b0..55ecc7a8b 100644 --- a/Gemfile +++ b/Gemfile @@ -40,11 +40,14 @@ group :test do gem 'rspec', '>= 2.0.0.beta.17' gem 'rspec-rails', '2.0.0.beta.17' gem 'mocha' - gem 'webrat' + gem 'webrat', '0.7.2.beta.1' gem 'redgreen' gem 'autotest' gem 'factory_girl_rails' gem 'database_cleaner' + gem 'saucelabs-adapter', '= 0.8.12' + gem 'selenium-rc' + gem 'json' end group :development do diff --git a/config/selenium.yml b/config/selenium.yml new file mode 100644 index 000000000..32bbc92fd --- /dev/null +++ b/config/selenium.yml @@ -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 : to localhost: + # 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: "" diff --git a/lib/tasks/saucelabs_adapter.rake b/lib/tasks/saucelabs_adapter.rake new file mode 100644 index 000000000..e9c32be08 --- /dev/null +++ b/lib/tasks/saucelabs_adapter.rake @@ -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 diff --git a/test/selenium/sample_webrat_test.rb b/test/selenium/sample_webrat_test.rb new file mode 100644 index 000000000..102985a97 --- /dev/null +++ b/test/selenium/sample_webrat_test.rb @@ -0,0 +1,7 @@ +class SampleWebratTest < ActionController::IntegrationTest + + def test_widget + visit "/" + assert_contain "sign in" + end +end diff --git a/test/selenium/selenium_suite.rb b/test/selenium/selenium_suite.rb new file mode 100644 index 000000000..2734b4309 --- /dev/null +++ b/test/selenium/selenium_suite.rb @@ -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') diff --git a/test/test_helper.rb b/test/test_helper.rb index 8bf1192ff..22895cbd0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,7 +7,7 @@ class ActiveSupport::TestCase # # Note: You'll currently still have to declare fixtures explicitly in integration tests # -- they do not yet inherit this setting - fixtures :all + #fixtures :all # Add more helper methods to be used by all tests here... end