Skip to content

Commit

Permalink
💄 Upgrade activerecord to version 4.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ogawatti committed Jul 28, 2014
1 parent f7ac6b5 commit 0325bb3
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 21 deletions.
2 changes: 1 addition & 1 deletion facemock.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency "activerecord", "~> 3.2.18"
spec.add_dependency "activerecord", "~> 4.1.4"
spec.add_dependency "sqlite3"
spec.add_dependency "fb_graph"

Expand Down
4 changes: 2 additions & 2 deletions lib/facemock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
module Facemock
extend self

def on
Facemock::FbGraph.on
def on(options={})
Facemock::FbGraph.on(options)
end

def off
Expand Down
2 changes: 0 additions & 2 deletions lib/facemock/config/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ def filepath

def create_applications_table
ActiveRecord::Migration.create_table :applications do |t|
t.integer :id, :null => false
t.string :secret, :null => false
end
end

def create_users_table
ActiveRecord::Migration.create_table :users do |t|
t.integer :id, :null => false
t.string :name, :null => false
t.string :email, :null => false
t.string :password, :null => false
Expand Down
14 changes: 12 additions & 2 deletions lib/facemock/fb_graph.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
require 'fb_graph'
require 'facemock/config'
require 'facemock/fb_graph/user'
require 'facemock/fb_graph/errors'
require "facemock/fb_graph/application"
require 'facemock/fb_graph/application'

module Facemock
module FbGraph
extend self

def on
def on(options={})
if ::FbGraph != Facemock::FbGraph
Object.const_set(:SourceFbGraph, ::FbGraph)
Object.send(:remove_const, :FbGraph) if Object.constants.include?(:FbGraph)
Object.const_set(:FbGraph, Facemock::FbGraph)
end

if options[:database_name]
Facemock::Config.database(options[:database_name])
else
Facemock::Config.database
end
true
end

def off
Expand All @@ -21,6 +29,8 @@ def off
Object.const_set(:FbGraph, ::SourceFbGraph)
Object.send(:remove_const, :SourceFbGraph) if Object.constants.include?(:FbGraph)
end
Facemock::Config.reset_database
true
end
end
end
5 changes: 0 additions & 5 deletions lib/facemock/fb_graph/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ def initialize(identifier, options={})
secret = options[:secret] || rand(36**32).to_s(36)
end

if options[:database_name]
Facemock::Config.database(options[:database_name])
else
Facemock::Config.database
end
super(secret: secret)
self.identifier = identifier
save! unless Application.find_by_id_and_secret(identifier, secret)
Expand Down
1 change: 0 additions & 1 deletion lib/facemock/fb_graph/application/user.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'active_record'
require 'facemock/fb_graph/application/user/right'
require 'pry'

module Facemock
module FbGraph
Expand Down
1 change: 0 additions & 1 deletion spec/facemock/config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'spec_helper'
require 'pry'

describe Facemock::Config do
let(:db_name) { ".test" }
Expand Down
10 changes: 7 additions & 3 deletions spec/facemock/fb_graph/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
it { is_expected.to eq table_name }
end

before { stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name) }
before do
stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
Facemock::Config.database
end
after { Facemock::Config.database.drop }

describe '#new' do
Expand All @@ -50,9 +53,10 @@
end
end

context 'with facebook app id and secret, database name option' do
context 'with facebook app id and secret' do
before do
options = { secret: facebook_app_secret, database_name: db_name }
options = { secret: facebook_app_secret }
Facemock::FbGraph.on
@app = Facemock::FbGraph::Application.new(facebook_app_id, options)
end

Expand Down
4 changes: 4 additions & 0 deletions spec/facemock/fb_graph/errors_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'spec_helper'

describe Facemock::FbGraph::Errors do
before do
Facemock::FbGraph.off
end

it 'should have a error module' do
expect(Facemock::FbGraph::Errors::Error).to be_truthy
expect(Facemock::FbGraph::Errors::Error.ancestors).to include StandardError
Expand Down
5 changes: 4 additions & 1 deletion spec/facemock/fb_graph/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
let(:db_directory) { File.expand_path("../../../../db", __FILE__) }
let(:db_filepath) { File.join(db_directory, "#{db_name}.#{adapter}") }

before { stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name) }
before do
stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
Facemock::Config.database
end
after { Facemock::Config.database.drop }

describe '.me' do
Expand Down
7 changes: 7 additions & 0 deletions spec/facemock/fb_graph_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'spec_helper'

describe Facemock::FbGraph do
let(:db_name) { ".test" }

it 'should have a application class' do
expect(Facemock::FbGraph::Application).to be_truthy
end
Expand All @@ -13,6 +15,11 @@
expect(Facemock::FbGraph::User).to be_truthy
end

before do
stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
end
after { Facemock::Config.database.drop }

describe '#on' do
subject { Facemock::FbGraph.on }
it { is_expected.to be_truthy }
Expand Down
24 changes: 21 additions & 3 deletions spec/facemock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe Facemock do
let(:version) { "0.0.1" }
let(:db_name) { ".test" }

describe 'VERSION' do
subject { Facemock::VERSION }
Expand All @@ -16,14 +17,31 @@
expect(Facemock::FbGraph).to be_truthy
end

before do
stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
end
after { Facemock::Config.database.drop }

describe '#on' do
subject { Facemock.on }
it { is_expected.to be_truthy }

context 'FbGraph' do
before { Facemock.on }
it { expect(::FbGraph).to eq Facemock::FbGraph }
it { expect( lambda { Facemock.on } ).not_to raise_error }
context 'without option' do
before { Facemock.on }
it { expect(::FbGraph).to eq Facemock::FbGraph }
it { expect( lambda { Facemock.on } ).not_to raise_error }
end

context 'with database_name option' do
before do
@options = { database_name: db_name}
Facemock.on(@options)
end
it { expect(::FbGraph).to eq Facemock::FbGraph }
it { expect( lambda { Facemock.on } ).not_to raise_error }
it { expect( lambda { Facemock.on(@options) } ).not_to raise_error }
end
end
end

Expand Down

0 comments on commit 0325bb3

Please sign in to comment.