Permalink
Browse files

More tests. Also adding confirmable to users.

  • Loading branch information...
1 parent 1b05512 commit d511751e6a659b67388d8a1b2b8f3828e48480bb @daronco committed Aug 5, 2011
View
@@ -2,6 +2,6 @@ bundler_args: "--without production"
before_script:
- "cp config/database.yml.example config/database.yml"
- "cp config/setup_conf.yml.example config/setup_conf.yml"
-script: bundle exec rake travis --trace 2>&1
+script: bundle exec rake travis
rvm:
- 1.9.2
@@ -3,7 +3,6 @@ class HomeController < ApplicationController
before_filter :authenticate_user!
def index
- @servers = BigbluebuttonServer.all
@rooms = BigbluebuttonRoom.where(:owner_type => "User", :owner_id => current_user.id)
end
View
@@ -1,7 +1,7 @@
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
- devise :database_authenticatable, :registerable,
+ devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
@@ -19,9 +19,9 @@
<div class="session_links">
<% if user_signed_in? %>
<%= link_to 'Account', edit_user_registration_path, :class => 'link' %>
- <%= link_to 'Logout', destroy_user_session_path, :class => 'link' %>
+ <%= link_to 'Logout', logout_path, :class => 'link' %>
<% else %>
- <%= link_to 'Login', new_user_session_path, :class => 'link' %>
+ <%= link_to 'Login', login_path, :class => 'link' %>
<%= link_to 'Register', new_user_registration_path, :class => 'link' %>
<% end %>
</div>
@@ -36,4 +36,8 @@
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
+
+ config.action_mailer.delivery_method = :test
+ config.action_mailer.perform_deliveries = true
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
end
@@ -5,13 +5,6 @@ def self.up
t.recoverable
t.rememberable
t.trackable
-
- # t.encryptable
- # t.confirmable
- # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
- # t.token_authenticatable
-
-
t.timestamps
end
@@ -0,0 +1,19 @@
+class AddConfirmableToUsers < ActiveRecord::Migration
+
+ def self.up
+ add_column :users, :confirmable, :integer
+ add_column :users, :confirmed_at, :datetime
+ add_column :users, :confirmation_token, :string
+ add_column :users, :confirmation_sent_at, :datetime
+ add_index :users, :confirmation_token, :unique => true
+ end
+
+ def self.down
+ remove_index :users, :confirmation_token
+ remove_column :users, :confirmable
+ remove_column :users, :confirmed_at
+ remove_column :users, :confirmation_token
+ remove_column :users, :confirmation_sent_at
+ end
+
+end
View
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110622025625) do
+ActiveRecord::Schema.define(:version => 20110805022300) do
create_table "bigbluebutton_rooms", :force => true do |t|
t.integer "server_id"
@@ -60,8 +60,13 @@
t.datetime "created_at"
t.datetime "updated_at"
t.string "name"
+ t.integer "confirmable"
+ t.datetime "confirmed_at"
+ t.string "confirmation_token"
+ t.datetime "confirmation_sent_at"
end
+ add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe HomeController do
+ render_views
+
+ describe "#index" do
+
+ pending "blocks access to unlogged users"
+
+ context "assigns current_user rooms" do
+ # TODO: try to use login_user
+ before {
+ @user = Factory.create(:user)
+ @rooms = [ Factory.create(:bigbluebutton_room, :owner => @user),
+ Factory.create(:bigbluebutton_room, :owner => @user) ]
+ 2.times { Factory.create(:bigbluebutton_room) }
+ sign_in @user
+ }
+ before(:each) { get :index }
+ it { should assign_to(:rooms).with(@rooms) }
+ end
+ end
+
+end
+
@@ -0,0 +1,12 @@
+Factory.define :bigbluebutton_room do |r|
+ r.association :server, :factory => :bigbluebutton_server
+ r.sequence(:meetingid) { |n| "MeetingID#{n}" }
+ r.sequence(:name) { |n| "Name#{n}" }
+ r.attendee_password { Forgery(:basic).password :at_least => 10, :at_most => 16 }
+ r.moderator_password { Forgery(:basic).password :at_least => 10, :at_most => 16 }
+ r.welcome_msg { Forgery(:lorem_ipsum).sentences(2) }
+ r.private false
+ r.randomize_meetingid false
+ r.sequence(:param) { |n| "meeting-#{n}" }
+ r.external false
+end
@@ -0,0 +1,7 @@
+Factory.define :bigbluebutton_server do |s|
+ s.sequence(:name) { |n| "Server #{n}" }
+ s.sequence(:url) { |n| "http://bigbluebutton#{n}.test.com/bigbluebutton/api" }
+ s.salt { Forgery(:basic).password :at_least => 30, :at_most => 40 }
+ s.version '0.7'
+ s.sequence(:param) { |n| "server-#{n}" }
+end
View
@@ -1,6 +1,7 @@
Factory.define :user do |u|
u.sequence(:name) { |n| "User Name #{n}" }
u.sequence(:email) { |n| "user#{n}@example.com" }
- u.password "test"
- u.password_confirmation "test"
+ u.password Forgery(:basic).password :at_least => 10, :at_most => 16
+ u.password_confirmation { |u| u.password }
+ u.after_create { |u| u.confirm! }
end
@@ -0,0 +1,29 @@
+require 'spec_helper'
+
+describe ApplicationHelper do
+
+ describe "#gravatar_for" do
+
+ it "default behavior" do
+ email = 'email@example.com'
+ url = 'http://www.gravatar.com/avatar/' + Digest::MD5::hexdigest(email.strip.downcase) + '.jpg?s=80'
+ expected = '<img alt="avatar" class="avatar" src="' + url + '" />'
+ gravatar_for(email).should eq(expected)
+ end
+
+ describe "accepts a hash with options" do
+ let(:gravatar) {
+ gravatar_for("email@example.com", { :alt => 'alt-1', :class => 'class-1', :size => '160', :style => 'any-1' })
+ }
+ it { gravatar.should match(/alt="alt-1"/) }
+ it { gravatar.should match(/class="class-1"/) }
+ it { gravatar.should match(/src="[^"]*jpg\?s=160"/) }
+ it { gravatar.should match(/style="any-1"/) }
+ end
+
+ end
+
+end
+
+
+
View
@@ -35,4 +35,9 @@
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
+
+ config.include Devise::TestHelpers, :type => :controller
+ config.extend ControllerMacros, :type => :controller
end
+
+FactoryGirl.find_definitions
@@ -0,0 +1,18 @@
+module ControllerMacros
+
+ def login_admin
+ before(:each) do
+ @request.env["devise.mapping"] = Devise.mappings[:admin]
+ sign_in Factory.create(:admin)
+ end
+ end
+
+ def login_user
+ before(:each) do
+ @request.env["devise.mapping"] = Devise.mappings[:user]
+ @user = Factory.create(:user)
+ sign_in @user
+ end
+ end
+
+end

0 comments on commit d511751

Please sign in to comment.