Skip to content

Commit

Permalink
Removed code made obsolete by Rails 4.0 final
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartl committed Jun 30, 2013
1 parent f6f278a commit d627dee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
1 change: 0 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class User < ActiveRecord::Base
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
has_secure_password
validates :password_confirmation, presence: true
validates :password, length: { minimum: 6 }

def feed
Expand Down
32 changes: 12 additions & 20 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe User do

before do
@user = User.new(name: "Example User", email: "user@example.com",
@user = User.new(name: "Example User", email: "user@example.com",
password: "foobar", password_confirmation: "foobar")
end

Expand Down Expand Up @@ -61,7 +61,7 @@
addresses.each do |invalid_address|
@user.email = invalid_address
expect(@user).not_to be_valid
end
end
end
end

Expand All @@ -71,7 +71,7 @@
addresses.each do |valid_address|
@user.email = valid_address
expect(@user).to be_valid
end
end
end
end

Expand All @@ -81,13 +81,13 @@
user_with_same_email.email = @user.email.upcase
user_with_same_email.save
end

it { should_not be_valid }
end

describe "when password is not present" do
before do
@user = User.new(name: "Example User", email: "user@example.com",
@user = User.new(name: "Example User", email: "user@example.com",
password: " ", password_confirmation: " ")
end
it { should_not be_valid }
Expand All @@ -98,14 +98,6 @@
it { should_not be_valid }
end

describe "when password confirmation is nil" do
before do
@user = User.new(name: "Michael Hartl", email: "mhartl@example.com",
password: "foobar", password_confirmation: nil)
end
it { should_not be_valid }
end

describe "with a password that's too short" do
before { @user.password = @user.password_confirmation = "a" * 5 }
it { should be_invalid }
Expand All @@ -131,17 +123,17 @@
before { @user.save }
its(:remember_token) { should_not be_blank }
end

describe "micropost associations" do

before { @user.save }
let!(:older_micropost) do
let!(:older_micropost) do
FactoryGirl.create(:micropost, user: @user, created_at: 1.day.ago)
end
let!(:newer_micropost) do
FactoryGirl.create(:micropost, user: @user, created_at: 1.hour.ago)
end

it "should have the right microposts in the right order" do
expect(@user.microposts.to_a).to eq [newer_micropost, older_micropost]
end
Expand Down Expand Up @@ -178,7 +170,7 @@
end

describe "following" do
let(:other_user) { FactoryGirl.create(:user) }
let(:other_user) { FactoryGirl.create(:user) }
before do
@user.save
@user.follow!(other_user)
Expand All @@ -191,10 +183,10 @@
subject { other_user }
its(:followers) { should include(@user) }
end

describe "and unfollowing" do
before { @user.unfollow!(other_user) }

it { should_not be_following(other_user) }
its(:followed_users) { should_not include(other_user) }
end
Expand Down

0 comments on commit d627dee

Please sign in to comment.