Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #180 from mezis/spec-fixes
Browse files Browse the repository at this point in the history
Spec fixes
  • Loading branch information
mezis committed Dec 31, 2013
2 parents 685e8ea + 32b0987 commit 6712c66
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class Account < ActiveRecord::Base
# attr_accessible :name, :auto_adopt, :domain, :categories

has_many :users, :dependent => :destroy
has_many :users, inverse_of: :account, :dependent => :destroy
has_many :ideas

validates_presence_of :name
Expand Down
2 changes: 1 addition & 1 deletion app/models/login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Login < ActiveRecord::Base
:trackable, :validatable,
:omniauthable

has_many :users, dependent: :destroy
has_many :users, inverse_of: :login, dependent: :destroy
has_many :accounts, through: :users

# attr_accessible :email, :password, :password_confirmation, :remember_me
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class User < ActiveRecord::Base

# attr_accessible :karma, :account, :voting_power, :login_attributes, :login

belongs_to :login
belongs_to :account
belongs_to :login, inverse_of: :users
belongs_to :account, inverse_of: :users

has_many :ideas, :foreign_key => :author_id, :dependent => :destroy
has_many :vettings, :dependent => :destroy
Expand Down
11 changes: 6 additions & 5 deletions spec/observers/karma/comment_observer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

describe Karma::CommentObserver do
context 'when a comment is posted' do
let(:author) { User.make! }
let(:idea) { Idea.make! }
let(:comment) { Comment.make! author: author, idea: idea }
fixtures :ideas, :users, :accounts, :logins

it 'the commenter gains karma' do
idea # make sure the idea is created outside the 'should' block
lambda { comment }.should change(author, :karma).by(1)
idea = ideas(:idea_submitted)
author = User.make!
lambda {
Comment.make! author: author, idea: idea
}.should change(author, :karma).by(1)
end
end
end

0 comments on commit 6712c66

Please sign in to comment.