Skip to content

Commit

Permalink
Merge pull request #51 from jhawthorn/fix_store_picker_js
Browse files Browse the repository at this point in the history
Fix store picker js
  • Loading branch information
jhawthorn authored Jun 22, 2016
2 parents c193ebc + cef5195 commit 16fec71
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
8 changes: 2 additions & 6 deletions lib/assets/javascripts/spree/backend/store_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $.fn.storeAutocomplete = function() {
multiple: true,
initSelection: function(element, callback) {
$.get(Spree.routes.store_search, { ids: element.val() }, function(data) {
callback(data.stores)
callback(data)
})
},
ajax: {
Expand All @@ -14,7 +14,7 @@ $.fn.storeAutocomplete = function() {
return { q: term }
},
results: function(data, page) {
return { results: data.stores }
return { results: data }
}
},
formatResult: function(store) {
Expand All @@ -28,7 +28,3 @@ $.fn.storeAutocomplete = function() {
}
});
}

$(document).ready(function () {
$('.store_picker').storeAutocomplete();
})
3 changes: 3 additions & 0 deletions solidus_multi_domain.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ Gem::Specification.new do |s|
s.add_development_dependency "coffee-rails"
s.add_development_dependency "factory_girl", "~> 4.5"
s.add_development_dependency "capybara"
s.add_development_dependency "poltergeist"
s.add_development_dependency "capybara-screenshot"
s.add_development_dependency "database_cleaner"
s.add_development_dependency "ffaker"
end
20 changes: 20 additions & 0 deletions spec/features/admin/promotion_rule_store_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'

RSpec.describe "Store promotion rule", js: true do
stub_authorization!

let!(:store) { create(:store, name: "Real fake doors") }
let!(:promotion) { create(:promotion) }

it "Can add a store rule to a promotion" do
visit spree.edit_admin_promotion_path(promotion)

select2 "Store", from: "Add rule of type"
within("#rules_container") { click_button "Add" }

select2_search store.name, from: "Choose Stores"

within("#rules_container") { click_button "Update" }
expect(page).to have_content('successfully updated')
end
end
27 changes: 25 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@
require 'rspec/rails'
require 'ffaker'

require 'database_cleaner'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
require 'capybara/poltergeist'
Capybara.register_driver(:poltergeist) do |app|
Capybara::Poltergeist::Driver.new app, timeout: 90
end
Capybara.javascript_driver = :poltergeist
Capybara.default_max_wait_time = 10

# Requires factories defined in spree_core
require 'spree/testing_support/factories'
require 'spree_multi_domain/testing_support/factory_overrides'
require 'spree/testing_support/controller_requests'
require 'spree/testing_support/authorization_helpers'
require 'spree/testing_support/preferences'

require 'spree/api/testing_support/helpers'
require 'spree/api/testing_support/setup'
require 'spree/testing_support/capybara_ext'

require 'cancan/matchers'

Expand All @@ -28,9 +38,22 @@

config.filter_run focus: true
config.run_all_when_everything_filtered = true
config.use_transactional_fixtures = true
config.use_transactional_fixtures = false

config.include FactoryGirl::Syntax::Methods
config.include Spree::TestingSupport::ControllerRequests, type: :controller
config.include Spree::Api::TestingSupport::Helpers, type: :controller

config.before :suite do
DatabaseCleaner.clean_with :truncation
end

config.before do
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
DatabaseCleaner.start
end

config.after do
DatabaseCleaner.clean
end
end

0 comments on commit 16fec71

Please sign in to comment.