* VRFS-1135 - user and band targetting possible

This commit is contained in:
Seth Call 2014-02-20 07:45:51 +00:00
parent 3efb3fc5ab
commit df14676495
18 changed files with 363 additions and 69 deletions

View File

@ -113,4 +113,5 @@ feed_use_recording.sql
feed_autoincrement_primary_key.sql
music_sessions_plays.sql
plays_likes_counters.sql
add_upright_bass.sql
add_upright_bass.sql
music_session_history_public.sql

View File

@ -0,0 +1 @@
ALTER TABLE music_sessions_history ADD COLUMN fan_access BOOLEAN NOT NULL;

View File

@ -36,17 +36,18 @@ module JamRuby
type_filter ||= 'all'
raise "not valid type #{type_filter}" unless TYPE_FILTERS.include?(type_filter)
include_private = params[:include_private]
include_private ||= false # default to false
include_private = false if user.nil? # and force to false if the current user is nil
target_user = params[:user]
target_band = params[:band]
query = Feed.includes([:recording]).includes([:music_session_history]).limit(limit)
#query = Feed.includes([:recording]).includes([:music_session_history]).limit(limit)
query = Feed.joins("LEFT OUTER JOIN recordings ON recordings.id = feeds.recording_id")
.joins("LEFT OUTER JOIN music_sessions_history ON music_sessions_history.id = feeds.music_session_id")
.limit(limit)
# handle sort
if sort == 'date'
query = query.where("id < #{start}")
query = query.order('id DESC')
query = query.where("feeds.id < #{start}")
query = query.order('feeds.id DESC')
elsif sort == 'plays'
query = query.offset(start)
query = query.order("COALESCE(recordings.play_count, music_sessions_history.play_count) DESC ")
@ -65,18 +66,64 @@ module JamRuby
# handle type filters
if type_filter == 'music_session_history'
query = query.where('music_session_id is not NULL')
query = query.where('feeds.music_session_id is not NULL')
elsif type_filter == 'recording'
query = query.where('recording_id is not NULL')
query = query.where('feeds.recording_id is not NULL')
end
# handle private times
if include_private
if target_user
if target_user != user.id
require_public_recordings = "claimed_recordings.is_public = TRUE AND"
require_public_sessions = "music_sessions_history.fan_access = TRUE AND"
end
query = query.joins("LEFT OUTER JOIN claimed_recordings ON recordings.id = claimed_recordings.recording_id AND #{require_public_recordings} (claimed_recordings.user_id = '#{target_user}' OR (recordings.band_id IN (SELECT band_id FROM bands_musicians where user_id='#{target_user}')))")
query = query.joins("LEFT OUTER JOIN music_sessions_user_history ON music_sessions_history.id = music_sessions_user_history.music_session_id AND #{require_public_sessions} music_sessions_user_history.user_id = '#{target_user}'")
query = query.group("feeds.id, feeds.recording_id, feeds.music_session_id, feeds.created_at, feeds.updated_at, recordings.id, music_sessions_history.id")
if sort == 'plays'
query = query.group("COALESCE(recordings.play_count, music_sessions_history.play_count)")
elsif sort == 'likes'
query = query.group("COALESCE(recordings.like_count, music_sessions_history.like_count)")
end
query = query.where('recordings.id is NULL OR claimed_recordings.id IS NOT NULL')
query = query.where('music_sessions_history.id is NULL OR music_sessions_user_history.id IS NOT NULL')
elsif target_band
unless Band.find(target_band).users.include?(user)
require_public_recordings = "claimed_recordings.is_public = TRUE AND"
require_public_sessions = "music_sessions_history.fan_access = TRUE AND"
end
query = query.joins("LEFT OUTER JOIN claimed_recordings ON recordings.id = claimed_recordings.recording_id AND #{require_public_recordings} recordings.band_id = '#{target_band}'")
query = query.where("music_sessions_history IS NULL OR #{require_public_sessions} music_sessions_history.band_id = '#{target_band}'")
query = query.group("feeds.id, feeds.recording_id, feeds.music_session_id, feeds.created_at, feeds.updated_at, recordings.id, music_sessions_history.id")
if sort == 'plays'
query = query.group("COALESCE(recordings.play_count, music_sessions_history.play_count)")
elsif sort == 'likes'
query = query.group("COALESCE(recordings.like_count, music_sessions_history.like_count)")
end
query = query.where('recordings.id is NULL OR claimed_recordings.id IS NOT NULL')
#query = query.where('music_sessions_history.id is NULL OR music_sessions_user_history.id IS NOT NULL')
else
query = query.joins('LEFT OUTER JOIN claimed_recordings ON recordings.id = claimed_recordings.recording_id AND claimed_recordings.is_public = TRUE')
query = query.joins("LEFT OUTER JOIN music_sessions_user_history ON music_sessions_history.id = music_sessions_user_history.music_session_id AND music_sessions_history.fan_access = TRUE")
query = query.group("feeds.id, feeds.recording_id, feeds.music_session_id, feeds.created_at, feeds.updated_at, recordings.id, music_sessions_history.id")
if sort == 'plays'
query = query.group("COALESCE(recordings.play_count, music_sessions_history.play_count)")
elsif sort == 'likes'
query = query.group("COALESCE(recordings.like_count, music_sessions_history.like_count)")
end
query = query.where('recordings.id is NULL OR claimed_recordings.is_public = TRUE')
query = query.where('music_sessions_history.id is NULL OR music_sessions_user_history.id IS NOT NULL')
end
if query.length == 0
[query, nil]
elsif query.length < limit

View File

@ -24,7 +24,7 @@ module JamRuby
has_many :recordings, :class_name => "JamRuby::Recording", :inverse_of => :music_session
belongs_to :band, :inverse_of => :music_sessions, :class_name => "JamRuby::Band", :foreign_key => "band_id"
after_save :require_at_least_one_genre, :limit_max_genres
after_save :require_at_least_one_genre, :limit_max_genres, :sync_music_session_history
after_destroy do |obj|
JamRuby::MusicSessionHistory.removed_music_session(obj.id)
@ -277,5 +277,9 @@ module JamRuby
end
end
end
def sync_music_session_history
MusicSessionHistory.save(self)
end
end
end

View File

@ -19,7 +19,7 @@ module JamRuby
:class_name => 'JamRuby::MusicSession',
:foreign_key => 'music_session_id')
has_many :music_session_user_histories, :class_name => "JamRuby::MusicSessionUserHistory", :foreign_key => "music_session_id"
has_many :music_session_user_histories, :class_name => "JamRuby::MusicSessionUserHistory", :foreign_key => "music_session_id", :dependent => :delete_all
has_many :comments, :class_name => "JamRuby::MusicSessionComment", :foreign_key => "music_session_id"
has_many :likes, :class_name => "JamRuby::MusicSessionLiker", :foreign_key => "session_id"
has_many :plays, :class_name => "JamRuby::MusicSessionPlay", :foreign_key => "music_session_id"
@ -131,6 +131,7 @@ module JamRuby
session_history.user_id = music_session.creator.id
session_history.band_id = music_session.band.id unless music_session.band.nil?
session_history.genres = music_session.genres.map { |g| g.id }.join SEPARATOR
session_history.fan_access = music_session.fan_access
session_history.save!
end

View File

@ -50,7 +50,7 @@ FactoryGirl.define do
factory :music_session do
after(:create) { |session|
MusicSessionHistory.save(session)
FactoryGirl.create(:music_session_user_history, :history => session.music_session_history, :user => session.creator)
}
factory :music_session_with_mount do
@ -66,6 +66,7 @@ FactoryGirl.define do
music_session nil
end
fan_access true
music_session_id { music_session.id }
description { music_session.description }
user_id { music_session.user_id }

View File

@ -23,7 +23,7 @@ describe ConnectionManager do
description = "some session"
@conn.exec("INSERT INTO music_sessions (user_id, description, musician_access, approval_required, fan_chat, fan_access) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id", [user_id, description, options[:musician_access], options[:approval_required], options[:fan_chat], options[:fan_access]]) do |result|
session_id = result.getvalue(0, 0)
@conn.exec("INSERT INTO music_sessions_history (music_session_id, description, user_id) VALUES ($1, $2, $3)", [session_id, description, user_id])
@conn.exec("INSERT INTO music_sessions_history (music_session_id, description, user_id, fan_access) VALUES ($1, $2, $3, $4)", [session_id, description, user_id, true])
return session_id
end
end

View File

@ -6,6 +6,7 @@ describe Feed do
let (:user2) { FactoryGirl.create(:user) }
let (:user3) { FactoryGirl.create(:user) }
let (:user4) { FactoryGirl.create(:user) }
let (:band) { FactoryGirl.create(:band) }
it "no result" do
feeds, start = Feed.index(user1)
@ -14,6 +15,7 @@ describe Feed do
it "one claimed recording" do
claimed_recording = FactoryGirl.create(:claimed_recording)
MusicSessionUserHistory.delete_all # the factory makes a music_session while making the recording/claimed_recording
MusicSessionHistory.delete_all # the factory makes a music_session while making the recording/claimed_recording
feeds, start = Feed.index(user1)
feeds.length.should == 1
@ -25,6 +27,7 @@ describe Feed do
second_track = FactoryGirl.create(:recorded_track, recording: recording)
recording.recorded_tracks << second_track
FactoryGirl.create(:claimed_recording, recording: recording, user: second_track.user)
MusicSessionUserHistory.delete_all # the factory makes a music_session while making the recording/claimed_recording
MusicSessionHistory.delete_all
# verify the mess above only made one recording
@ -41,6 +44,16 @@ describe Feed do
feeds[0].music_session_history == music_session.music_session_history
end
it "does not return a recording with no claimed recordings" do
recording = FactoryGirl.create(:recording)
MusicSessionUserHistory.delete_all # the factory makes a music_session while making the recording/claimed_recording
MusicSessionHistory.delete_all
feeds, start = Feed.index(user1)
feeds.length.should == 0
end
describe "sorting" do
it "sorts by index (date) DESC" do
claimed_recording = FactoryGirl.create(:claimed_recording)
@ -242,6 +255,205 @@ describe Feed do
end
end
describe "public feed" do
it "only public" do
claimed_recording1 = FactoryGirl.create(:claimed_recording)
claimed_recording1.is_public = false
claimed_recording1.save!
feeds, start = Feed.index(claimed_recording1.user)
feeds.length.should == 1
claimed_recording1.recording.music_session.fan_access = false
claimed_recording1.recording.music_session.save!
feeds, start = Feed.index(claimed_recording1.user)
feeds.length.should == 0
end
end
describe "band feeds" do
it "does show other band's stuff in this feed" do
other_band = FactoryGirl.create(:band)
music_session = FactoryGirl.create(:music_session, band: other_band)
FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => user1)
claimed_recording1 = FactoryGirl.create(:claimed_recording)
claimed_recording1.is_public = true
claimed_recording1.recording.band = other_band
claimed_recording1.recording.save!
claimed_recording1.save!
feeds, start = Feed.index(user1, band: band.id)
feeds.length.should == 0
end
it "shows public recordings to you and to others" do
user1.bands << band
user1.save!
music_session = FactoryGirl.create(:music_session, band: band)
music_session.music_session_history.fan_access.should be_true
feeds, start = Feed.index(user1, band: band.id)
feeds.length.should == 1
feeds[0].music_session_history.should == music_session.music_session_history
feeds, start = Feed.index(user2, band: band.id)
feeds.length.should == 1
feeds[0].music_session_history.should == music_session.music_session_history
end
it "shows private sessions to you, not to others" do
user1.bands << band
user1.save!
music_session = FactoryGirl.create(:music_session, band: band, fan_access: false)
music_session.music_session_history.fan_access.should be_false
feeds, start = Feed.index(user1, band: band.id)
feeds.length.should == 1
feeds[0].music_session_history.should == music_session.music_session_history
feeds[0].music_session_history.fan_access.should be_false
feeds, start = Feed.index(user2, band: band.id)
feeds.length.should == 0
end
it "shows public recordings to you and to others" do
claimed_recording1 = FactoryGirl.create(:claimed_recording)
claimed_recording1.is_public = true
claimed_recording1.recording.band = band
claimed_recording1.recording.save!
claimed_recording1.save!
feeds, start = Feed.index(claimed_recording1.user, band: band.id)
feeds.length.should == 1
feeds[0].recording.should == claimed_recording1.recording
feeds, start = Feed.index(user1, band: band.id)
feeds.length.should == 1
feeds[0].recording.should == claimed_recording1.recording
end
it "shows private recordings to you, not to others" do
claimed_recording1 = FactoryGirl.create(:claimed_recording)
claimed_recording1.is_public = false
claimed_recording1.recording.band = band
claimed_recording1.recording.save!
claimed_recording1.save!
claimed_recording1.user.bands << band
claimed_recording1.user.save!
feeds, start = Feed.index(claimed_recording1.user, band: band.id)
feeds.length.should == 1
feeds[0].recording.should == claimed_recording1.recording
feeds, start = Feed.index(user1, band: band.id)
feeds.length.should == 0
end
end
describe "user feeds" do
it "does not show stuff from other people" do
music_session = FactoryGirl.create(:music_session)
FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => user2)
claimed_recording1 = FactoryGirl.create(:claimed_recording)
claimed_recording1.is_public = true
claimed_recording1.save!
feeds, start = Feed.index(user1, user: user1.id)
feeds.length.should == 0
end
it "shows public sessions to you and to others" do
music_session = FactoryGirl.create(:music_session)
FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => user1)
feeds, start = Feed.index(user1, user: user1.id)
feeds.length.should == 1
feeds[0].music_session_history.should == music_session.music_session_history
feeds, start = Feed.index(user2, user: user1.id)
feeds.length.should == 1
feeds[0].music_session_history.should == music_session.music_session_history
end
it "shows private sessions to you, not to others" do
music_session = FactoryGirl.create(:music_session, fan_access: false)
music_session.music_session_history.fan_access.should be_false
FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => user1)
feeds, start = Feed.index(user1, user: user1.id)
feeds.length.should == 1
feeds[0].music_session_history.should == music_session.music_session_history
feeds[0].music_session_history.fan_access.should be_false
feeds, start = Feed.index(user2, user: user1.id)
feeds.length.should == 0
end
it "shows public recordings to you and to others" do
claimed_recording1 = FactoryGirl.create(:claimed_recording)
claimed_recording1.is_public = true
claimed_recording1.save!
feeds, start = Feed.index(claimed_recording1.user, user: claimed_recording1.user.id)
feeds.length.should == 1
feeds[0].recording.should == claimed_recording1.recording
feeds, start = Feed.index(user1, user: claimed_recording1.user.id)
feeds.length.should == 1
feeds[0].recording.should == claimed_recording1.recording
end
it "shows private recordings to you, not to others" do
claimed_recording1 = FactoryGirl.create(:claimed_recording)
claimed_recording1.is_public = false
claimed_recording1.save!
feeds, start = Feed.index(claimed_recording1.user, user: claimed_recording1.user.id)
feeds.length.should == 1
feeds[0].recording.should == claimed_recording1.recording
feeds, start = Feed.index(user1, user: claimed_recording1.user.id)
feeds.length.should == 0
end
it "shows band recordings to you even though you did not claim a recording" do
user1.bands << band
user1.save!
user2.bands << band
user2.save!
claimed_recording1 = FactoryGirl.create(:claimed_recording, user: user2)
claimed_recording1.is_public = true
claimed_recording1.recording.band = band
claimed_recording1.recording.save!
claimed_recording1.save!
feeds, start = Feed.index(user1, user: user1.id)
feeds.length.should == 1
feeds[0].recording.should == claimed_recording1 .recording
# make it private; should still be available
claimed_recording1.is_public = false
claimed_recording1.save!
feeds, start = Feed.index(user1, user: user1.id)
feeds.length.should == 1
feeds[0].recording.should == claimed_recording1 .recording
# take user1 out of the band; shouldn't be able to see it
user1.bands.delete_all
feeds, start = Feed.index(user1, user: user1.id)
feeds.length.should == 0
end
end
end

View File

@ -4,18 +4,17 @@ describe MusicSessionHistory do
let(:some_user) { FactoryGirl.create(:user) }
let(:music_session) { FactoryGirl.create(:music_session_no_history) }
let(:history) { FactoryGirl.create(:music_session_history, :music_session => music_session) }
let(:user_history1) { FactoryGirl.create(:music_session_user_history, :history => history, :user => music_session.creator) }
let(:user_history2) { FactoryGirl.create(:music_session_user_history, :history => history, :user => some_user) }
let(:user_history1) { FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => music_session.creator) }
let(:user_history2) { FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => some_user) }
it "create" do
history.description.should eql(music_session.description)
music_session.music_session_history.description.should eql(music_session.description)
end
it "unique users" do
user_history1.should_not be_nil
user_history2.should_not be_nil
users = history.unique_users
users = music_session.music_session_history.unique_users
users.length.should eql(2)

View File

@ -4,9 +4,8 @@ describe MusicSessionUserHistory do
let(:some_user) { FactoryGirl.create(:user) }
let(:music_session) { FactoryGirl.create(:music_session_no_history) }
let(:history) { FactoryGirl.create(:music_session_history, :music_session => music_session) }
let(:user_history1) { FactoryGirl.create(:music_session_user_history, :history => history, :user => music_session.creator) }
let(:user_history2) { FactoryGirl.create(:music_session_user_history, :history => history, :user => some_user) }
let(:user_history1) { FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => music_session.creator) }
let(:user_history2) { FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => some_user) }
describe "create" do
it {user_history1.music_session_id.should == music_session.id }
@ -78,7 +77,7 @@ describe MusicSessionUserHistory do
end
it "two histories with same user within bounds of history1" do
user_history3 = FactoryGirl.create(:music_session_user_history, :history => history, :user => some_user)
user_history3 = FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => some_user)
# if user2 comes and goes 2 times while user one is there, it shouldn't be a false 3
user_history1.session_removed_at = user_history1.created_at + 5
@ -99,7 +98,7 @@ describe MusicSessionUserHistory do
it "two histories with different user within bounds of history1" do
third_user = FactoryGirl.create(:user);
user_history3 = FactoryGirl.create(:music_session_user_history, :history => history, :user => third_user)
user_history3 = FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => third_user)
# if user2 comes and goes 2 times while user one is there, it shouldn't be a false 3
user_history1.session_removed_at = user_history1.created_at + 5
@ -120,7 +119,7 @@ describe MusicSessionUserHistory do
it "two overlapping histories with different user within bounds of history1" do
third_user = FactoryGirl.create(:user);
user_history3 = FactoryGirl.create(:music_session_user_history, :history => history, :user => third_user)
user_history3 = FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => third_user)
# if user2 comes and goes 2 times while user one is there, it shouldn't be a false 3
user_history1.session_removed_at = user_history1.created_at + 5

View File

@ -61,6 +61,7 @@ Spork.prefork do
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.color_enabled = true
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus

View File

@ -54,7 +54,6 @@ gem 'fog'
gem 'haml-rails'
gem 'unf' #optional fog dependency
gem 'devise', '>= 1.1.2'
gem 'puma' # the presence of this gem on mac seems to prevent normal startup of rails.
gem 'postgres-copy'
#group :libv8 do
# gem 'libv8', "~> 3.11.8"

View File

@ -8,7 +8,9 @@ class ApiFeedsController < ApiController
limit: params[:limit],
sort: params[:sort],
time_range: params[:time_range],
type: params[:type])
type: params[:type],
user: params[:user],
band: params[:band])
render "api_feeds/index", :layout => nil
end

View File

@ -43,9 +43,6 @@ MusicSessionManager < BaseManager
# save session parameters for next session
User.save_session_settings(user, music_session)
# save session history
MusicSessionHistory.save(music_session)
# auto-join this user into the newly created session
as_musician = true
connection = ConnectionManager.new.join_music_session(user, client_id, music_session, as_musician, tracks)
@ -96,12 +93,9 @@ MusicSessionManager < BaseManager
update[:genres] = genre_array
end
if music_session.update_attributes(update)
# save session history (only thing that could change is description)
MusicSessionHistory.save(music_session)
end
music_session.update_attributes(update)
return music_session
music_session
end
def participant_create(user, music_session_id, client_id, as_musician, tracks)

View File

@ -9,6 +9,7 @@ describe ApiFeedsController do
before(:each) do
MusicSession.delete_all
MusicSessionUserHistory.delete_all
MusicSessionHistory.delete_all
Recording.delete_all
end
@ -23,6 +24,7 @@ describe ApiFeedsController do
it "returns a recording" do
claimed_recording.touch
# artifact of factory of :claimed_recording that this gets created
MusicSessionUserHistory.delete_all
MusicSessionHistory.delete_all
get :index
@ -109,4 +111,29 @@ describe ApiFeedsController do
_next.should be_nil
end
end
describe "user targetting" do
it "user viewing own profile" do
pending 'not tested'
music_session.fan_access = false
music_session.save!
controller.current_user = music_session.creator
get :index
json = JSON.parse(response.body, :symbolize_names => true)
json[:entries].length.should == 1
end
it "user viewing someone else's profile" do
pending 'not tested'
music_session.fan_access = false
music_session.save!
controller.current_user = user
get :index
json = JSON.parse(response.body, :symbolize_names => true)
json[:entries].length.should == 0
end
end
end

View File

@ -52,12 +52,20 @@ FactoryGirl.define do
association :creator, :factory => :user
after(:create) { |session|
MusicSessionHistory.save(session)
FactoryGirl.create(:music_session_user_history, :history => session.music_session_history, :user => session.creator)
}
end
factory :music_session_user_history, :class => JamRuby::MusicSessionUserHistory do
ignore do
history nil
user nil
end
music_session_id { history.music_session_id }
user_id { user.id }
sequence(:client_id) { |n| "Connection #{n}" }
end

View File

@ -1,6 +1,6 @@
require 'simplecov'
require 'rubygems'
require 'spork'
#require 'spork'
require 'omniauth'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
@ -33,44 +33,23 @@ ActionMailer::Base.delivery_method = :test
RecordedTrack.observers.disable :all # only a few tests want this observer active
Spork.prefork do
#Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
#require 'rspec/autorun'
require 'capybara'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
driver = Capybara::Poltergeist::Driver.new(app, { debug: false, phantomjs_logger: File.open('log/phantomjs.out', 'w') })
end
Capybara.javascript_driver = :poltergeist
Capybara.default_wait_time = 10
if defined?(TEST_CONNECT_STATES) && TEST_CONNECT_STATES
TEST_CONNECT_STATE_JS_CONSOLE_IO = File.open(TEST_CONNECT_STATE_JS_CONSOLE, 'w')
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, { phantomjs_logger: TEST_CONNECT_STATE_JS_CONSOLE_IO })
end
Capybara.javascript_driver = :poltergeist
end
Capybara.configure do |config|
config.match = :one
config.exact_options = true
config.ignore_hidden_elements = true
config.visible_text_only = true
end
Capybara.server do |app, port|
require 'rack/handler/puma'
Rack::Handler::Puma.run(app, :Port => port)
end
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
@ -79,6 +58,25 @@ Spork.prefork do
ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base)
RSpec.configure do |config|
Capybara.register_driver :poltergeist do |app|
driver = Capybara::Poltergeist::Driver.new(app, { debug: false, phantomjs_logger: File.open('log/phantomjs.out', 'w') })
end
Capybara.javascript_driver = :poltergeist
Capybara.default_wait_time = 10
Capybara.configure do |config|
config.match = :one
config.exact_options = true
config.ignore_hidden_elements = true
config.visible_text_only = true
config.run_server = false
end
Capybara.server do |app, port|
raise "gaaag"
require 'rack/handler/puma'
Rack::Handler::Puma.run(app, :Port => port)
end
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
@ -154,12 +152,12 @@ Spork.prefork do
wipe_s3_test_bucket
end
end
end
#end
Spork.each_run do
#Spork.each_run do
# This code will be run each time you run your specs.
end
#end

View File

@ -56,8 +56,8 @@ end
def sign_in_poltergeist(user)
visit signin_path
fill_in "Email Address:", with: user.email
fill_in "Password:", with: user.password
fill_in "session_email", with: user.email
fill_in "session_password", with: user.password
click_button "SIGN IN"
if Capybara.javascript_driver == :poltergeist