forked from danielvlopes/railsmg
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
admin column should be false by default, update models and update specs
- Loading branch information
Showing
9 changed files
with
101 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
class Notifier < ActionMailer::Base | ||
def signup_confirmation user | ||
recipients user.email_with_name | ||
subject 'RailsMG # Confirmação de conta' | ||
from 'donotreply@railsmg.com.br' | ||
subject 'RailsMG - Confirmação de conta' | ||
from 'donotreply@railsmg.org' | ||
body :user => user | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class UserSession < Authlogic::Session::Base | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
db/migrate/20100124192406_change_default_value_for_admin.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class ChangeDefaultValueForAdmin < ActiveRecord::Migration | ||
def self.up | ||
change_column_default :users, :admin, false | ||
end | ||
|
||
def self.down | ||
raise ActiveRecord::IrreversibleMigration | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,35 @@ | ||
require 'spec_helper' | ||
|
||
describe Meeting do | ||
before do | ||
@meeting = Meeting.make | ||
end | ||
|
||
# Upload | ||
should_have_attached_file(:slide_preview, :styles => { :medium => "267x345>", :thumb => "116x150>" }) | ||
|
||
# Database | ||
should_have_column :name, :type => :string | ||
# database | ||
should_have_columns :name, :video, :code, :slides, :type => :string | ||
should_have_column :description, :type => :text | ||
should_have_column :start_on, :type => :date | ||
|
||
# Associations | ||
# asssociations | ||
should_belong_to :user | ||
|
||
# Scopes | ||
|
||
# plugins | ||
should_have_attached_file :slide_preview, :styles => { :medium => "267x345>", :thumb => "116x150>" } | ||
|
||
# scopes | ||
should_have_default_scope :order => 'start_on DESC' | ||
|
||
# Validations | ||
# validations | ||
should_validate_presence_of :name, :description | ||
|
||
# FIXME: Find a way to be more DRY | ||
describe "when seting a url" do | ||
before :all do | ||
@good_urls = "http://slideshare.net/slide1", "http://github.com/danielvlopes" | ||
@bad_urls = "slideshare.net", "http://github/danielvlopes" | ||
end | ||
|
||
it { should allow_values_for :slides, @good_urls } | ||
it { should_not allow_values_for :slides, @bad_urls } | ||
it { should allow_values_for :video, @good_urls } | ||
it { should_not allow_values_for :video, @bad_urls } | ||
it { should allow_values_for :code, @good_urls } | ||
it { should_not allow_values_for :code, @bad_urls } | ||
end | ||
|
||
with_options :allow_blank => true do |m| | ||
m.should_validate_length_of :name, :in => 1..255 | ||
m.should_validate_uniqueness_of :name, :scope => :user_id, :case_sensitive => false | ||
# TODO: remarkable fix: m.should_validate_uniqueness_of :name, :scope => :user_id, :case_sensitive => false | ||
end | ||
|
||
%w(slides video code).each do |attribute| | ||
should_allow_values_for attribute, "http://slideshare.net/slide1", "http://github.com/danielvlopes" | ||
should_not_allow_values_for attribute, "slideshare.net", "http://github/danielvlopes" | ||
end | ||
|
||
it 'to_s should return name' do | ||
@meeting.name.should be_eql(@meeting.name) | ||
subject.name = 'Nome da Palestra' | ||
subject.to_s.should eql 'Nome da Palestra' | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
describe Project do | ||
before do | ||
@project = Project.make | ||
end | ||
|
||
# Database | ||
# database | ||
should_have_columns :name, :description, :type => :string | ||
should_have_column :user_id, :type => :integer | ||
should_have_index :user_id | ||
|
||
# Scopes | ||
should_have_default_scope :order => 'projects.name' | ||
|
||
# Associations | ||
# associations | ||
should_belong_to :user, :counter_cache => true | ||
|
||
# Validations | ||
# scopes | ||
should_have_default_scope :order => 'projects.name' | ||
|
||
# validations | ||
should_validate_presence_of :user, :name | ||
|
||
with_options :allow_blank => true do |p| | ||
p.should_validate_length_of :name, :description, :in => 1..255 | ||
p.should_validate_uniqueness_of :name, :scope => :user_id, :case_sensitive => false | ||
# TODO: remarkable fix: p.should_validate_uniqueness_of :name, :scope => :user_id, :case_sensitive => false | ||
end | ||
|
||
it 'to_s should return name' do | ||
@project.to_s.should be_eql(@project.name) | ||
subject.name = 'Nome do Projeto' | ||
subject.to_s.should eql 'Nome do Projeto' | ||
end | ||
end | ||
|
||
it 'github_url should return a valid github url' do | ||
subject.user = mock_model(User, :github => 'sobrinho') | ||
subject.name = 'projeto' | ||
|
||
subject.github_url.should eql 'http://github.com/sobrinho/projeto' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,58 @@ | ||
require 'spec_helper' | ||
|
||
describe User do | ||
before do | ||
@user = User.make | ||
end | ||
# database | ||
should_have_columns :name, :github, :email, :crypted_password, :password_salt, :persistence_token, | ||
:perishable_token, :city, :site, :twitter, :type => :string | ||
should_have_column :projects_count, :default => 0, :type => :integer | ||
should_have_column :using_ruby_since, :type => :integer | ||
should_have_column :about, :type => :text | ||
should_have_columns :public_email, :active, :admin, :type => :boolean, :default => false | ||
|
||
# Database | ||
should_have_columns :name, :github, :email, :crypted_password, :password_salt, | ||
:persistence_token, :perishable_token, :city, :type => :string | ||
should_have_column :projects_count, :type => :integer, :default => 0 | ||
should_have_indices :email, :persistence_token, :unique => true | ||
|
||
# Scopes | ||
# scopes | ||
should_have_default_scope :order => 'users.name' | ||
|
||
should_have_named_scope :with_projects, :include => :projects, :order => 'users.name, projects.name' | ||
should_have_named_scope :active, :conditions => { :active => true } | ||
|
||
# Associations | ||
# associations | ||
should_have_many :projects, :meetings | ||
|
||
# Validations | ||
should_validate_presence_of :name, :email | ||
# validations | ||
should_validate_presence_of :name, :email, :city | ||
should_validate_length_of :password, :minimum => 6, :if => :require_password? | ||
should_validate_confirmation_of :password, :if => :require_password? | ||
|
||
with_options :allow_blank => true do |u| | ||
u.should_validate_length_of :name, :city, :github, :in => 1..255 | ||
# FIXME: u.should_validate_as_email :email | ||
u.should_validate_uniqueness_of :email, :case_sensitive => false | ||
# FIXME: u.should_validate_uniqueness_of :github, :case_sensitive => false | ||
# TODO: remarkable fix: u.should_validate_uniqueness_of :email, :case_sensitive => false | ||
# TODO: remarkable fix: u.should_validate_uniqueness_of :github, :case_sensitive => false | ||
end | ||
|
||
should_allow_values_for :email, '[email protected]', '[email protected]' | ||
should_not_allow_values_for :email, 'john@doe', 'john.doe' | ||
|
||
should_allow_values_for :github, 'john', 'jonh_doe' | ||
should_not_allow_values_for :github, 'jonhn doe', 'john.doe' | ||
|
||
it 'active should be on protected attributes' do | ||
User.protected_attributes.should be_include 'active' | ||
User.protected_attributes.should include 'active' | ||
User.protected_attributes.should include 'admin' | ||
end | ||
|
||
it 'to_s should return name' do | ||
@user.to_s.should be_eql(@user.name) | ||
subject.name = 'Gabriel Sobrinho' | ||
subject.to_s.should eql 'Gabriel Sobrinho' | ||
end | ||
|
||
it 'active! should set active as true' do | ||
User.active!(@user.perishable_token).should be_eql @user | ||
@user.reload | ||
@user.active.should be_true | ||
user = User.make | ||
|
||
User.active!(user.perishable_token).should eql user | ||
|
||
user.reload | ||
user.active.should be true | ||
end | ||
end | ||
|