Commit 87635b14
Changed files (3)
spec
spec/features/upload_creation_spec.rb
@@ -1,30 +1,31 @@
require "rails_helper"
describe "uploading a new creation", :js => true do
- let!(:user) { create(:user, :password => "password") }
+ let!(:user) { create(:user, password: "password") }
let!(:category_1) { create(:category) }
let!(:category_2) { create(:category) }
before :each do
visit user_session_path
within('.form-inline') do
- fill_in('user_email', :with => user.email)
- fill_in('user_password', :with => "password")
+ fill_in('user_email', with: user.email)
+ fill_in('user_password', with: "password")
end
click_button("Sign In")
+ click_link("avatar-link")
click_link("Add Creation")
-
+ wait_for_ajax
within(".form-horizontal") do
- fill_in("creation_name", :with => "yummy cake")
- fill_in("creation_watermark", :with => "yummy")
- fill_in("creation_story", :with => "this was just so damn yummy so i ate it alone.")
- select(category_2.name, :from => 'creation_category_id')
- #fill_in("creation_tags", :with => "cake, yummy")
+ fill_in("cake_name", with: "yummy cake")
+ fill_in("cake_watermark", with: "yummy")
+ fill_in("cake_story", with: "this was just so damn yummy so i ate it alone.")
+ select(category_2.name, from: 'cake_category_id')
+ #fill_in("cake_tags", :with => "cake, yummy")
end
- click_button("NEXT STEP")
+ click_button("Create")
end
it "should get them to the image upload page" do
- page.should have_content("Step 2 of 2")
+ expect(page).to have_text("yummy cake")
end
end
spec/support/wait_for_ajax.rb
@@ -0,0 +1,11 @@
+module WaitForAjax
+ def wait_for_ajax
+ Timeout.timeout(Capybara.default_wait_time) do
+ loop until finished_all_ajax_requests?
+ end
+ end
+
+ def finished_all_ajax_requests?
+ page.evaluate_script('jQuery.active').zero?
+ end
+end
spec/rails_helper.rb
@@ -24,7 +24,7 @@ RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
- #config.use_transactional_fixtures = true
+ config.use_transactional_fixtures = false
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
@@ -40,8 +40,9 @@ RSpec.configure do |config|
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!
- config.include DeviseHelper::Controllers, :type => :controller
- config.include Devise::TestHelpers, :type => :controller
+ config.include DeviseHelper::Controllers, type: :controller
+ config.include Devise::TestHelpers, type: :controller
+ config.include WaitForAjax, type: :feature
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
@@ -49,9 +50,12 @@ RSpec.configure do |config|
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
- config.before(:each, :js => true) do
+ config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
end
+ #config.before(:each, :js => true) do
+ #DatabaseCleaner.strategy = :truncation
+ #end
config.before(:each) do
DatabaseCleaner.start
end