-
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.
Merge pull request #47 from cheshire137/add-anoyn-user
Add anonymous user
- Loading branch information
Showing
4 changed files
with
28 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 |
---|---|---|
|
@@ -7,4 +7,8 @@ class User < ApplicationRecord | |
devise :omniauthable, omniauth_providers: [:bnet] | ||
|
||
has_many :compositions, dependent: :destroy | ||
|
||
def self.anonymous | ||
find_by_email "[email protected]" | ||
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 |
---|---|---|
|
@@ -72,3 +72,9 @@ | |
MapSegment.create(map_id: map.id, name: segment) | ||
end | ||
end | ||
|
||
puts "Creating anonymous user" | ||
User.create( | ||
email: "[email protected]", | ||
password: "passworD1" | ||
) |
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,4 +1,9 @@ | ||
FactoryGirl.define do | ||
factory :anonymous_user, class: User do | ||
email "[email protected]" | ||
password "passworD1" | ||
end | ||
|
||
factory :composition do | ||
map | ||
user | ||
|
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,4 +1,17 @@ | ||
require 'rails_helper' | ||
|
||
describe User do | ||
context "Anonymous user" do | ||
before do | ||
create :anonymous_user | ||
end | ||
|
||
it "found via email" do | ||
expect(User.find_by_email("[email protected]")).to_not be_nil | ||
end | ||
|
||
it "found via anonymous method" do | ||
expect(User.anonymous).to_not be_nil | ||
end | ||
end | ||
end |