-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from abdullahallmehedi/49514_RSpec_for_UsersCo…
…urse_Model RSpec for UsersCourse Model 49514
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "faker" | ||
|
||
FactoryGirl.define do | ||
factory :users_course do | ||
user | ||
course | ||
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require "rails_helper" | ||
|
||
describe UsersCourse do | ||
let(:demo_obj) {FactoryGirl.build :users_course} | ||
subject {FactoryGirl.create :users_course} | ||
|
||
it {is_expected.to be_an UsersCourse} | ||
it {expect belong_to :user} | ||
it {expect belong_to :course} | ||
|
||
it "triggers .appened_assigned_users on save" do | ||
expect(demo_obj).to receive :appened_assigned_users | ||
demo_obj.save | ||
end | ||
|
||
it "triggers .appened_removed_users on destroy" do | ||
demo_obj.save | ||
expect(demo_obj).to receive :appened_removed_users | ||
demo_obj.destroy | ||
end | ||
|
||
it {expect(demo_obj.course.assigned_users).not_to include demo_obj.user} | ||
context "checking callbacks internal functionality" do | ||
before {demo_obj.save} | ||
|
||
it {expect(demo_obj.course.assigned_users).to include demo_obj.user} | ||
it "appened_removed_users" do | ||
demo_obj.destroy | ||
expect(demo_obj.course.assigned_users).to include demo_obj.user | ||
end | ||
end | ||
end |