Commit 68369978
Changed files (4)
db
spec
db/migrate/20140927141151_create_locations.rb
@@ -1,7 +1,7 @@
class CreateLocations < ActiveRecord::Migration
def change
create_table :locations, id: :uuid do |t|
- t.integer :locatable_id
+ t.uuid :locatable_id
t.string :locatable_type
t.string :latitude
t.string :longitude
db/schema.rb
@@ -14,8 +14,8 @@
ActiveRecord::Schema.define(version: 20140929024135) do
# These are extensions that must be enabled in order to support this database
- enable_extension "uuid-ossp"
enable_extension "plpgsql"
+ enable_extension "uuid-ossp"
create_table "activities", force: true do |t|
t.integer "subject_id", null: false
@@ -31,8 +31,8 @@ ActiveRecord::Schema.define(version: 20140929024135) do
create_table "avatars", force: true do |t|
t.integer "user_id"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.string "avatar"
t.boolean "avatar_processing"
t.string "avatar_tmp"
@@ -85,8 +85,8 @@ ActiveRecord::Schema.define(version: 20140929024135) do
t.datetime "failed_at"
t.string "locked_by"
t.string "queue"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
@@ -103,12 +103,12 @@ ActiveRecord::Schema.define(version: 20140929024135) do
create_table "interests", force: true do |t|
t.string "name"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "locations", id: :uuid, default: "uuid_generate_v4()", force: true do |t|
- t.integer "locatable_id"
+ t.uuid "locatable_id"
t.string "locatable_type"
t.string "latitude"
t.string "longitude"
@@ -157,13 +157,15 @@ ActiveRecord::Schema.define(version: 20140929024135) do
t.integer "taggings_count", default: 0
end
+ add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
+
create_table "tutorials", force: true do |t|
t.string "heading"
t.text "description"
t.string "url"
t.integer "user_id"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.string "image_url"
t.string "author"
t.string "author_url"
@@ -192,12 +194,12 @@ ActiveRecord::Schema.define(version: 20140929024135) do
add_index "user_sessions", ["user_id"], name: "index_user_sessions_on_user_id", using: :btree
create_table "users", force: true do |t|
- t.string "email", default: "", null: false
- t.string "encrypted_password", limit: 128, default: "", null: false
+ t.string "email", default: "", null: false
+ t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
- t.integer "sign_in_count", default: 0
+ t.integer "sign_in_count", default: 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
@@ -216,13 +218,13 @@ ActiveRecord::Schema.define(version: 20140929024135) do
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
- t.integer "failed_attempts", default: 0
+ t.integer "failed_attempts", default: 0
t.string "unlock_token"
t.datetime "locked_at"
t.string "authentication_token"
t.string "invitation_token"
t.string "full_address"
- t.integer "creations_count", default: 0
+ t.integer "creations_count", default: 0
t.boolean "admin"
end
spec/models/location_spec.rb
@@ -3,7 +3,8 @@ require 'rails_helper'
describe Location do
describe "#create" do
it 'can create a new location' do
- location = Location.create!(latitude: '100', longitude: '100', city: 'Calgary', country: 'Canada')
+ session = create(:user_session)
+ location = Location.create!(latitude: '100', longitude: '100', city: 'Calgary', country: 'Canada', locatable: session)
expect(location).to_not be_nil
expect(location.latitude).to eql('100')
expect(location.longitude).to eql('100')
spec/models/user_session_spec.rb
@@ -13,10 +13,11 @@ describe UserSession do
describe "#access" do
let(:request) { double(ip: '192.168.1.1', user_agent: 'blah') }
let(:location) { build(:location) }
- let!(:because) { subject.access(request) }
+ let(:because) { subject.access(request) }
before :each do
Location.stub(:build_from_ip).with('192.168.1.1').and_return(location)
+ because
end
it "records the time the session was accessed" do