Created
August 27, 2013 23:43
-
-
Save jianbo/6360486 to your computer and use it in GitHub Desktop.
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
require 'spec_helper' | |
describe "Search", :js => true, :search => true do | |
subject { page } | |
let(:job) { Sunspot::Queue::Sidekiq::IndexJob.new } | |
before(:all) do | |
Toon.delete_all | |
max_user_id = User.maximum("id") | |
max_user_id = max_user_id.nil? ? 0 : max_user_id | |
user1 = User.create! :first_name => "Alexander", :last_name => "Elizabeth", :gender => "m", :birth_date => Time.now - 20.years, :country => "United States", :username => "user#{max_user_id + 1}", :email => "user#{max_user_id + 1}@example.com", :password => 'please', :password_confirmation => 'please', :avatar => 'ToonHeroBlack.jpg' | |
user1.confirm! | |
test_icon_s3_path = 'https://s3.amazonaws.com/projectassetsdevelopment/F3A290FA-6616-47D2-91EB-20F7482F49BF/F3A290FA-6616-47D2-91EB-20F7482F49BF.png' | |
@toon1 = Toon.create!(:uuid => "AAA-BBB#{rand(10000)}", :name => 'Test Toon #{user1.id} - 1', :author => 'David Jackson', | |
:json => %{[some json two]}, :icon_s3_path => test_icon_s3_path, :user_id => user1.id, :toon_type => "animation"); | |
@toon2 = Toon.create!(:uuid => "AAA-BBB#{rand(10000)}", :name => 'Test Toon #{user1.id} - 2', :author => 'David Jackson', | |
:json => %{[some json two]}, :icon_s3_path => test_icon_s3_path, :user_id => user1.id, :toon_type => "animation"); | |
@toon3 = Toon.create!(:uuid => "AAA-BBB#{rand(10000)}", :name => 'Test Toon #{user1.id} - 2', :author => 'David Jackson', | |
:json => %{[some json two]}, :icon_s3_path => test_icon_s3_path, :user_id => user1.id, :toon_type => "animation"); | |
@toon4 = Toon.create!(:uuid => "AAA-BBB#{rand(10000)}", :name => 'Test Toon #{user1.id} - 2', :author => 'Alexander Hanson', | |
:json => %{[some json two]}, :icon_s3_path => test_icon_s3_path, :user_id => user1.id, :toon_type => "animation"); | |
@toon5 = Toon.create!(:uuid => "AAA-BBB#{rand(10000)}", :name => 'Test Toon #{user1.id} - 2', :author => 'Alexander Hanson', | |
:json => %{[some json two]}, :icon_s3_path => test_icon_s3_path, :user_id => user1.id, :toon_type => "animation"); | |
@toon6 = Toon.create!(:uuid => "AAA-BBB#{rand(10000)}", :name => 'Test Toon #{user1.id} - 2', :author => 'Alexander Hanson', | |
:json => %{[some json two]}, :icon_s3_path => test_icon_s3_path, :user_id => user1.id, :toon_type => "animation"); | |
@toon7 = Toon.create!(:uuid => "AAA-BBB#{rand(10000)}", :name => 'Test Toon #{user1.id} - 2', :author => 'Alexander Hanson', | |
:json => %{[some json two]}, :icon_s3_path => test_icon_s3_path, :user_id => user1.id, :toon_type => "animation"); | |
@toon8 = Toon.create!(:uuid => "AAA-BBB#{rand(10000)}", :name => 'Test Toon #{user1.id} - 2', :author => 'Alexander Hanson', | |
:json => %{[some json two]}, :icon_s3_path => test_icon_s3_path, :user_id => user1.id, :toon_type => "animation"); | |
@toon9 = Toon.create!(:uuid => "AAA-BBB#{rand(10000)}", :name => 'Test Toon #{user1.id} - 2', :author => 'Alexander Hanson', | |
:json => %{[some json two]}, :icon_s3_path => test_icon_s3_path, :user_id => user1.id, :toon_type => "animation") | |
end | |
describe "search page", :search => true do | |
before(:each){ | |
visit "/" | |
} | |
it { | |
job.perform(Toon, @toon1.id) | |
Sunspot.commit | |
job.perform(Toon, @toon2.id) | |
Sunspot.commit | |
job.perform(Toon, @toon3.id) | |
Sunspot.commit | |
job.perform(Toon, @toon4.id) | |
Sunspot.commit | |
job.perform(Toon, @toon5.id) | |
Sunspot.commit | |
job.perform(Toon, @toon6.id) | |
Sunspot.commit | |
job.perform(Toon, @toon7.id) | |
Sunspot.commit | |
job.perform(Toon, @toon8.id) | |
Sunspot.commit | |
job.perform(Toon, @toon9.id) | |
Sunspot.commit | |
sleep 4 | |
fill_in "search-sidenav", with: "Alexander Hanson" | |
page.execute_script("$('#search-form').submit()") | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment