Skip to content

Commit

Permalink
Merge pull request #47 from cheshire137/add-anoyn-user
Browse files Browse the repository at this point in the history
Add anonymous user
  • Loading branch information
cheshire137 authored Mar 8, 2017
2 parents 022519a + c663252 commit c4cf612
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
5 changes: 5 additions & 0 deletions spec/factories.rb
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
Expand Down
13 changes: 13 additions & 0 deletions spec/models/user_spec.rb
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

0 comments on commit c4cf612

Please sign in to comment.