diff --git a/.gitignore b/.gitignore index cc57f49..e733944 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,11 @@ .DS_Store .idea .project +.sass-cache +coverage +Gemfile.lock tmp nbproject +pkg *.swp -spec/test_app +spec/dummy \ No newline at end of file diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..5052887 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..a69695d --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +source 'https://rubygems.org' + +gem 'spree', github: 'spree/spree', branch: '2-2-stable' +# Provides basic authentication functionality for testing parts of your engine +gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-2-stable' + +gemspec diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..36c6695 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,320 @@ +GIT + remote: git://github.com/spree/spree.git + revision: accd271e961e14a095540ef8b2f47b955b538774 + branch: 2-2-stable + specs: + spree (2.2.9.beta) + spree_api (= 2.2.9.beta) + spree_backend (= 2.2.9.beta) + spree_cmd (= 2.2.9.beta) + spree_core (= 2.2.9.beta) + spree_frontend (= 2.2.9.beta) + spree_sample (= 2.2.9.beta) + spree_api (2.2.9.beta) + rabl (= 0.9.3) + spree_core (= 2.2.9.beta) + versioncake (~> 1.2.0) + spree_backend (2.2.9.beta) + jquery-rails (~> 3.1.2) + jquery-ui-rails (~> 4.1.0) + select2-rails (~> 3.4.7) + spree_api (= 2.2.9.beta) + spree_core (= 2.2.9.beta) + spree_cmd (2.2.9.beta) + thor (~> 0.14) + spree_core (2.2.9.beta) + activemerchant (~> 1.43.1) + acts_as_list (= 0.3.0) + awesome_nested_set (~> 3.0.0.rc.3) + aws-sdk (= 1.27.0) + cancan (~> 1.6.10) + deface (~> 1.0.0) + ffaker (~> 1.16) + font-awesome-rails (~> 4.0) + friendly_id (~> 5.0.4) + highline (~> 1.6.18) + httparty (~> 0.11) + i18n (= 0.6.9) + json (~> 1.7) + kaminari (~> 0.15.0) + monetize + paperclip (~> 3.4.1) + paranoia (~> 2.0) + rails (~> 4.0.12) + ransack (~> 1.1.0) + state_machine (= 1.2.0) + stringex (~> 1.5.1) + truncate_html (= 0.9.2) + spree_frontend (2.2.9.beta) + canonical-rails (~> 0.0.4) + jquery-rails (~> 3.1.2) + spree_api (= 2.2.9.beta) + spree_core (= 2.2.9.beta) + stringex (~> 1.5.1) + spree_sample (2.2.9.beta) + spree_core (= 2.2.9.beta) + +GIT + remote: git://github.com/spree/spree_auth_devise.git + revision: 01901766a2562026e2f3eb523a3f0f9bea8ae31e + branch: 2-2-stable + specs: + spree_auth_devise (2.2.0) + cancan (~> 1.6.10) + devise (~> 3.2.3) + devise-encryptable (= 0.1.2) + json + multi_json + spree_core (~> 2.2.0) + +PATH + remote: . + specs: + spree_waiting_list (1.0.0) + haml (~> 4.0.6) + spree_core (~> 2.2.2) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.0.12) + actionpack (= 4.0.12) + mail (~> 2.5, >= 2.5.4) + actionpack (4.0.12) + activesupport (= 4.0.12) + builder (~> 3.1.0) + erubis (~> 2.7.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + active_utils (2.2.3) + activesupport (>= 2.3.11) + i18n + activemerchant (1.43.3) + active_utils (~> 2.0, >= 2.0.1) + activesupport (>= 2.3.14, < 5.0.0) + builder (>= 2.1.2, < 4.0.0) + i18n (~> 0.5) + json (~> 1.7) + money (< 7.0.0) + nokogiri (~> 1.4) + activemodel (4.0.12) + activesupport (= 4.0.12) + builder (~> 3.1.0) + activerecord (4.0.12) + activemodel (= 4.0.12) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.12) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.3) + activesupport (4.0.12) + i18n (~> 0.6, >= 0.6.9) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + acts_as_list (0.3.0) + activerecord (>= 3.0) + arel (4.0.2) + awesome_nested_set (3.0.1) + activerecord (>= 4.0.0, < 5) + aws-sdk (1.27.0) + json (~> 1.4) + nokogiri (>= 1.4.4) + uuidtools (~> 2.1) + bcrypt (3.1.9) + builder (3.1.4) + cancan (1.6.10) + canonical-rails (0.0.7) + rails (>= 3.1, < 5.0) + capybara (2.4.4) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + childprocess (0.5.5) + ffi (~> 1.0, >= 1.0.11) + climate_control (0.0.3) + activesupport (>= 3.0) + cocaine (0.5.5) + climate_control (>= 0.0.3, < 1.0) + coffee-rails (4.1.0) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.3.0) + coffee-script-source + execjs + coffee-script-source (1.8.0) + colorize (0.7.3) + database_cleaner (1.3.0) + deface (1.0.1) + colorize (>= 0.5.8) + nokogiri (~> 1.6.0) + polyglot + rails (>= 3.1) + devise (3.2.4) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 3.2.6, < 5) + thread_safe (~> 0.1) + warden (~> 1.2.3) + devise-encryptable (0.1.2) + devise (>= 2.1.0) + diff-lcs (1.2.5) + docile (1.1.5) + erubis (2.7.0) + execjs (2.2.2) + factory_girl (4.5.0) + activesupport (>= 3.0.0) + ffaker (1.25.0) + ffi (1.9.6) + font-awesome-rails (4.2.0.0) + railties (>= 3.2, < 5.0) + friendly_id (5.0.4) + activerecord (>= 4.0.0) + haml (4.0.6) + tilt + highline (1.6.21) + hike (1.2.3) + httparty (0.13.3) + json (~> 1.8) + multi_xml (>= 0.5.2) + i18n (0.6.9) + jquery-rails (3.1.2) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + jquery-ui-rails (4.1.2) + railties (>= 3.1.0) + json (1.8.1) + kaminari (0.15.1) + actionpack (>= 3.0.0) + activesupport (>= 3.0.0) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mime-types (2.4.3) + mini_portile (0.6.1) + minitest (4.7.5) + monetize (1.0.0) + money (~> 6.4.0) + money (6.4.0) + i18n (>= 0.6.4, <= 0.7.0.beta1) + multi_json (1.10.1) + multi_xml (0.5.5) + nokogiri (1.6.5) + mini_portile (~> 0.6.0) + orm_adapter (0.5.0) + paperclip (3.4.2) + activemodel (>= 3.0.0) + activerecord (>= 3.0.0) + activesupport (>= 3.0.0) + cocaine (~> 0.5.0) + mime-types + paranoia (2.0.4) + activerecord (~> 4.0) + polyamorous (0.6.4) + activerecord (>= 3.0) + polyglot (0.3.5) + rabl (0.9.3) + activesupport (>= 2.3.14) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.0.12) + actionmailer (= 4.0.12) + actionpack (= 4.0.12) + activerecord (= 4.0.12) + activesupport (= 4.0.12) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.12) + sprockets-rails (~> 2.0) + railties (4.0.12) + actionpack (= 4.0.12) + activesupport (= 4.0.12) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.4.2) + ransack (1.1.0) + actionpack (>= 3.0) + activerecord (>= 3.0) + polyamorous (~> 0.6.0) + rspec-collection_matchers (1.1.2) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (2.99.2) + rspec-expectations (2.99.2) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.99.2) + rspec-rails (2.99.0) + actionpack (>= 3.0) + activemodel (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-collection_matchers + rspec-core (~> 2.99.0) + rspec-expectations (~> 2.99.0) + rspec-mocks (~> 2.99.0) + rubyzip (1.1.6) + sass (3.2.19) + sass-rails (4.0.5) + railties (>= 4.0.0, < 5.0) + sass (~> 3.2.2) + sprockets (~> 2.8, < 3.0) + sprockets-rails (~> 2.0) + select2-rails (3.4.9) + sass-rails + thor (~> 0.14) + selenium-webdriver (2.44.0) + childprocess (~> 0.5) + multi_json (~> 1.0) + rubyzip (~> 1.0) + websocket (~> 1.0) + simplecov (0.9.1) + docile (~> 1.1.0) + multi_json (~> 1.0) + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) + sprockets (2.12.3) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.2.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + sqlite3 (1.3.10) + state_machine (1.2.0) + stringex (1.5.1) + thor (0.19.1) + thread_safe (0.3.4) + tilt (1.4.1) + truncate_html (0.9.2) + tzinfo (0.3.42) + uuidtools (2.1.5) + versioncake (1.2.0) + actionpack (>= 3.2) + activesupport (>= 3.2) + railties (>= 3.2) + tzinfo + warden (1.2.3) + rack (>= 1.0) + websocket (1.2.1) + xpath (2.0.0) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + capybara (~> 2.1) + coffee-rails + database_cleaner + factory_girl (~> 4.4) + ffaker + rspec-rails (~> 2.13) + sass-rails + selenium-webdriver + simplecov + spree! + spree_auth_devise! + spree_waiting_list! + sqlite3 diff --git a/README.md b/README.md index 73aef67..ea1a71c 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,37 @@ Users and guests can request to be notified via email when a product/variant com Installation -======= +------------ -Instructions to go here +Add spree_waiting_list to your Gemfile: + +```ruby +gem 'spree_waiting_list' +``` + +Bundle your dependencies and run the installation generator: + +```shell +bundle +bundle exec rails g spree_waiting_list:install +``` + +Testing +------- + +First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`. + +```shell +bundle +bundle exec rake +``` + +When testing your applications integration with this extension you may use it's factories. +Simply add this require statement to your spec_helper: + +```ruby +require 'spree_waiting_list/factories' +``` Copyright (c) 2011 Joshua Nussbaum, released under the New BSD License diff --git a/Rakefile b/Rakefile index cd56b7d..2f55065 100644 --- a/Rakefile +++ b/Rakefile @@ -1,68 +1,21 @@ -require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rake/packagetask' -require 'rake/gempackagetask' - -spec = eval(File.read('spree_waiting_list.gemspec')) - -Rake::GemPackageTask.new(spec) do |p| - p.gem_spec = spec -end - -desc "Release to gemcutter" -task :release => :package do - require 'rake/gemcutter' - Rake::Gemcutter::Tasks.new(spec).define - Rake::Task['gem:push'].invoke -end - -desc "Default Task" -task :default => [ :spec ] +require 'bundler' +Bundler::GemHelper.install_tasks require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new +require 'spree/testing_support/extension_rake' -# require 'cucumber/rake/task' -# Cucumber::Rake::Task.new do |t| -# t.cucumber_opts = %w{--format pretty} -# end - -desc "Regenerates a rails 3 app for testing" -task :test_app do - SPREE_PATH = ENV['SPREE_PATH'] - raise "SPREE_PATH should be specified" unless SPREE_PATH - require File.join(SPREE_PATH, 'lib/generators/spree/test_app_generator') - class WaitingListTestAppGenerator < Spree::Generators::TestAppGenerator - def tweak_gemfile - append_file 'Gemfile' do - <<-gems - gem 'spree_core', :path => '#{File.join(SPREE_PATH, 'core')}' - gem 'spree_auth', :path => '#{File.join(SPREE_PATH, 'auth')}' - gem 'spree_waiting_list', :path => '#{File.dirname(__FILE__)}' - gems - end - end - - def install_gems - inside "test_app" do - run 'rake spree_core:install' - run 'rake spree_auth:install' - end - - generate 'spree_waiting_list:install -f' - end +RSpec::Core::RakeTask.new - def migrate_db - run_migrations - end +task :default do + if Dir["spec/dummy"].empty? + Rake::Task[:test_app].invoke + Dir.chdir("../../") end - WaitingListTestAppGenerator.start + Rake::Task[:spec].invoke end -namespace :test_app do - desc 'Rebuild test and cucumber databases' - task :rebuild_dbs do - system("cd spec/test_app && rake db:drop db:migrate RAILS_ENV=test && rake db:drop db:migrate RAILS_ENV=cucumber") - end +desc 'Generates a dummy app for testing' +task :test_app do + ENV['LIB_NAME'] = 'spree_waiting_list' + Rake::Task['extension:test_app'].invoke end diff --git a/app/controllers/admin/reports_controller_decorator.rb b/app/controllers/admin/reports_controller_decorator.rb deleted file mode 100644 index 9f273d2..0000000 --- a/app/controllers/admin/reports_controller_decorator.rb +++ /dev/null @@ -1,18 +0,0 @@ -Admin::ReportsController::AVAILABLE_REPORTS[:stock_requests] = {:name => 'Stock Requests', :description => 'Out of stock product requests'} - -Admin::ReportsController.class_eval do - - def stock_requests - @search = StockRequest.search(params[:search]) - - respond_to do |format| - format.html do - @stock_requests = @search.page(params[:page]) - end - format.csv do - @stock_requests = @search.all - end - end - end - -end diff --git a/app/controllers/spree/admin/reports_controller_decorator.rb b/app/controllers/spree/admin/reports_controller_decorator.rb new file mode 100644 index 0000000..4cd3936 --- /dev/null +++ b/app/controllers/spree/admin/reports_controller_decorator.rb @@ -0,0 +1,18 @@ +Spree::Admin::ReportsController.add_available_report! :stock_requests + +Spree::Admin::ReportsController.class_eval do + + def stock_requests + @search = Spree::StockRequest.search(params[:search]) + + respond_to do |format| + format.html do + @stock_requests = @search.page(params[:page]) + end + format.csv do + @stock_requests = @search.all + end + end + end + +end diff --git a/app/controllers/spree/stock_requests_controller.rb b/app/controllers/spree/stock_requests_controller.rb new file mode 100644 index 0000000..0808894 --- /dev/null +++ b/app/controllers/spree/stock_requests_controller.rb @@ -0,0 +1,32 @@ +module Spree + class StockRequestsController < StoreController + layout false + + def new + @stock_request = StockRequest.new(stock_request_params) + end + + def create + @stock_request = StockRequest.new(stock_request_params) + @stock_request.email = try_spree_current_user.email if try_spree_current_user + + respond_to do |format| + if @stock_request.save + format.html { redirect_to root_path, :notice => Spree.t(:successful_stock_request) } + format.js + else + format.html { render :action => 'new'} + format.json { render json: @stock_request.errors, status: :unprocessable_entity } + end + end + end + + private + + def stock_request_params + params.require(:stock_request).permit(permitted_attributes.stock_request_attributes) + end + + end +end + diff --git a/app/controllers/stock_requests_controller.rb b/app/controllers/stock_requests_controller.rb deleted file mode 100644 index 9c99935..0000000 --- a/app/controllers/stock_requests_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -class StockRequestsController < Spree::BaseController - def new - @stock_request = StockRequest.new(params[:stock_request]) - end - - def create - @stock_request = StockRequest.new(params[:stock_request]) - @stock_request.email = current_user.email if current_user - - if @stock_request.save - respond_to do |format| - format.html { redirect_to root_path, :notice => t(:successful_stock_request) } - format.js - end - else - render :action => 'new' - end - end -end diff --git a/app/mailers/spree/user_mailer_decorator.rb b/app/mailers/spree/user_mailer_decorator.rb new file mode 100644 index 0000000..03e21e5 --- /dev/null +++ b/app/mailers/spree/user_mailer_decorator.rb @@ -0,0 +1,11 @@ +Spree::UserMailer.class_eval do + def back_in_stock(stock_request) + @request = stock_request + @product = stock_request.product + @variant = stock_request.variant + + mail(:subject => Spree.t(:back_in_stock_subject, :product_name => @product.name), + :from => from_address, + :to => stock_request.email) + end +end \ No newline at end of file diff --git a/app/mailers/user_mailer_decorator.rb b/app/mailers/user_mailer_decorator.rb deleted file mode 100644 index 02c342c..0000000 --- a/app/mailers/user_mailer_decorator.rb +++ /dev/null @@ -1,11 +0,0 @@ -UserMailer.class_eval do - def back_in_stock(request) - @request = request - @product = request.product - @variant = request.variant - - mail(:subject => t("back_in_stock_subject", :product_name => @product.name), - :from => Spree::Config[:order_from], - :to => request.email) - end -end diff --git a/app/models/spree/permitted_attributes_decorator.rb b/app/models/spree/permitted_attributes_decorator.rb new file mode 100644 index 0000000..02987f7 --- /dev/null +++ b/app/models/spree/permitted_attributes_decorator.rb @@ -0,0 +1,16 @@ +Spree::PermittedAttributes.class_eval do + @@stock_request_attributes = [:email, :product_id, :variant_id] +end + +module Spree + module PermittedAttributes + + class << self + + mattr_reader :stock_request_attributes + + ATTRIBUTES << :stock_request_attributes + + end + end +end \ No newline at end of file diff --git a/app/models/product_decorator.rb b/app/models/spree/product_decorator.rb similarity index 51% rename from app/models/product_decorator.rb rename to app/models/spree/product_decorator.rb index 16f8a47..565b06c 100644 --- a/app/models/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -1,3 +1,3 @@ -Product.class_eval do +Spree::Product.class_eval do has_many :stock_requests end diff --git a/app/models/spree/stock_item_decorator.rb b/app/models/spree/stock_item_decorator.rb new file mode 100644 index 0000000..e25437a --- /dev/null +++ b/app/models/spree/stock_item_decorator.rb @@ -0,0 +1,21 @@ +module Spree + + StockItem.class_eval do + + around_save :notify_availability + + private + def notify_availability + available = count_on_hand_was <= 0 && count_on_hand > 0 && count_on_hand_changed? + + yield + + if available + variant.stock_requests.notified(false).each &:notify! + variant.product.stock_requests.without_variant.notified(false).each &:notify! + end + end + + end + +end \ No newline at end of file diff --git a/app/models/spree/stock_request.rb b/app/models/spree/stock_request.rb new file mode 100644 index 0000000..5a4105d --- /dev/null +++ b/app/models/spree/stock_request.rb @@ -0,0 +1,29 @@ +module Spree + class StockRequest < ActiveRecord::Base + belongs_to :product + belongs_to :variant + + validates :email, :presence => true, + :format => {with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i} + + default_scope { order('created_at desc') } + + scope :notified, lambda { |is_notified| where(:status => is_notified ? 'notified' : 'new') } + scope :without_variant, -> { where(:variant_id => nil) } + + state_machine :status, :initial => 'new' do + event :notify do + transition :from => 'new', :to => 'notified' + end + + after_transition :to => 'notified', :do => :send_email + end + + private + + def send_email + UserMailer.back_in_stock(self).deliver + end + + end +end diff --git a/app/models/spree/variant_decorator.rb b/app/models/spree/variant_decorator.rb new file mode 100644 index 0000000..a248b71 --- /dev/null +++ b/app/models/spree/variant_decorator.rb @@ -0,0 +1,7 @@ +module Spree + + Variant.class_eval do + has_many :stock_requests + end + +end diff --git a/app/models/stock_request.rb b/app/models/stock_request.rb deleted file mode 100644 index eca99e8..0000000 --- a/app/models/stock_request.rb +++ /dev/null @@ -1,27 +0,0 @@ -class StockRequest < ActiveRecord::Base - belongs_to :product - belongs_to :variant - - validates :email, :presence => true, - :format => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i - - default_scope order('created_at desc') - - scope :notified, lambda {|is_notified| where(:status => is_notified ? 'notified' : 'new') } - scope :without_variant, where(:variant_id => nil) - - state_machine :status, :initial => 'new' do - event :notify do - transition :from => 'new', :to => 'notified' - end - - after_transition :to => 'notified', :do => :send_email - end - -private - - def send_email - UserMailer.back_in_stock(self).deliver - end - -end diff --git a/app/models/variant_decorator.rb b/app/models/variant_decorator.rb deleted file mode 100644 index 68d9589..0000000 --- a/app/models/variant_decorator.rb +++ /dev/null @@ -1,17 +0,0 @@ -Variant.class_eval do - has_many :stock_requests - - around_save :notify_availability - -private - def notify_availability - available = count_on_hand_was <= 0 && count_on_hand > 0 && count_on_hand_changed? - - yield - - if available - stock_requests.notified(false).each &:notify! - product.stock_requests.without_variant.notified(false).each &:notify! - end - end -end diff --git a/app/views/admin/reports/stock_requests.csv.erb b/app/views/spree/admin/reports/stock_requests.csv.erb similarity index 100% rename from app/views/admin/reports/stock_requests.csv.erb rename to app/views/spree/admin/reports/stock_requests.csv.erb diff --git a/app/views/admin/reports/stock_requests.html.haml b/app/views/spree/admin/reports/stock_requests.html.haml similarity index 60% rename from app/views/admin/reports/stock_requests.html.haml rename to app/views/spree/admin/reports/stock_requests.html.haml index a4ea8ae..771f2fc 100644 --- a/app/views/admin/reports/stock_requests.html.haml +++ b/app/views/spree/admin/reports/stock_requests.html.haml @@ -1,18 +1,18 @@ .toolbar %ul.actions %li - = button_link_to t("download"), stock_requests_admin_reports_path(@search.search_attributes.merge(:format => :csv)), {:icon => 'xls'} + = button_link_to Spree.t(:download), stock_requests_admin_reports_path(@search.search_attributes.merge(:format => :csv)), {:icon => 'xls'} %br.clear -%h1= t(:stock_requests) +%h1= Spree.t(:stock_requests) %table.index %tr %th= sort_link @search, :email - %th= t(:product) - %th= t(:variant) + %th= Spree.t(:product) + %th= Spree.t(:variant) %th= sort_link @search, :status - %th= sort_link @search, :created_at, t(:requested) + %th= sort_link @search, :created_at, Spree.t(:requested) - @stock_requests.each do |stock_request| %tr{:class => cycle('even','odd')} @@ -22,19 +22,19 @@ %td= stock_request.status.titleize %td = time_ago_in_words(stock_request.created_at) - = t(:ago) + = Spree.t(:ago) = paginate @stock_requests - content_for :sidebar do = form_for @search, :url => stock_requests_admin_reports_path do |f| .box - %h3= t(:search) + %h3= Spree.t(:search) %p - = f.label :product_variants_sku_contains, t(:sku) + = f.label :product_variants_sku_contains, Spree.t(:sku) = f.text_field :product_variants_sku_contains, :size => 15 %p - = f.label :status_equals, t(:status) - = f.select :status_equals, %w(new notified).collect {|s| [s.titleize,s]}, :include_blank => t(:show_all) + = f.label :status_equals, Spree.t(:status) + = f.select :status_equals, %w(new notified).collect {|s| [s.titleize,s]}, :include_blank => Spree.t(:show_all) %p.form-buttons - = button t("search") + = button Spree.t(:search) diff --git a/app/views/stock_requests/create.js.erb b/app/views/spree/stock_requests/create.js.erb similarity index 100% rename from app/views/stock_requests/create.js.erb rename to app/views/spree/stock_requests/create.js.erb diff --git a/app/views/spree/stock_requests/new.html.haml b/app/views/spree/stock_requests/new.html.haml new file mode 100644 index 0000000..a40694e --- /dev/null +++ b/app/views/spree/stock_requests/new.html.haml @@ -0,0 +1,12 @@ +%h1= Spree.t(:new_stock_request) + = render "spree/shared/error_messages", :target => @stock_request + = form_for @stock_request do |f| + = f.hidden_field :product_id + = f.hidden_field :variant_id + %p + = f.label :email + - if spree_current_user + = spree_current_user.email + - else + = f.text_field :email + = f.submit Spree.t(:submit_stock_request) \ No newline at end of file diff --git a/app/views/user_mailer/back_in_stock.text.erb b/app/views/spree/user_mailer/back_in_stock.text.erb similarity index 100% rename from app/views/user_mailer/back_in_stock.text.erb rename to app/views/spree/user_mailer/back_in_stock.text.erb diff --git a/app/views/stock_requests/new.html.haml b/app/views/stock_requests/new.html.haml deleted file mode 100644 index 0a26aa4..0000000 --- a/app/views/stock_requests/new.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -%h1= t("new_stock_request") -= render "shared/error_messages", :target => @stock_request -= form_for @stock_request do |f| - = f.hidden_field :product_id - = f.hidden_field :variant_id - %p - = f.label :email - - if current_user - = current_user.email - - else - = f.text_field :email - = f.submit t('submit_stock_request') diff --git a/bin/rails b/bin/rails new file mode 100644 index 0000000..ea80eb6 --- /dev/null +++ b/bin/rails @@ -0,0 +1,7 @@ +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + +ENGINE_ROOT = File.expand_path('../..', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/spree_waiting_list/engine', __FILE__) + +require 'rails/all' +require 'rails/engine/commands' diff --git a/config/locales/en.yml b/config/locales/en.yml index 8059847..cbed5d6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,14 +1,16 @@ --- en: - back_in_stock_subject: Hey! %{product_name} is back in stock - successful_stock_request: Thanks! we will notify you as soon as the item is back in stock - new_stock_request: Request New Stock Notification - submit_stock_request: Send Request - stock_requests: Stock Requests out_of_stock_product_requests: Requests for out of stock products - created_at: Created - ago: ago - variant: Variant - download: Download - show_all: Show all - requested: requested + spree: + stock_requests: Stock Requests + created_at: Created + ago: ago + show_all: Show all + download: Download + variant: Variant + back_in_stock_subject: Hey! %{product_name} is back in stock + successful_stock_request: Thanks! we will notify you as soon as the item is back in stock + stock_requests_description: 'Out of stock product requests' + new_stock_request: Request New Stock Notification + submit_stock_request: Send Request + requested: requested diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml new file mode 100644 index 0000000..9f8fc78 --- /dev/null +++ b/config/locales/pt-BR.yml @@ -0,0 +1,16 @@ +--- +pt-BR: + out_of_stock_product_requests: Solicitações para produtos sem estoque + spree: + stock_requests: Solicitações de Produtos Indisponíveis + created_at: Criado + ago: atrás + show_all: Mostrar todos + download: Download + variant: Variante + back_in_stock_subject: Olá! %{product_name} está disponível novamente + successful_stock_request: Obrigado! Nós o notificaremos assim que o produto estiver disponível + stock_requests_description: Solicitações de Produtos não disponíveis + new_stock_request: Nova Solicitação de Produto Indisponível + submit_stock_request: Enviar Solicitação + requested: solicitado diff --git a/config/routes.rb b/config/routes.rb index 3402f7a..186e2ac 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ -Rails.application.routes.draw do +Spree::Core::Engine.routes.draw do resources :stock_requests namespace :admin do diff --git a/lib/generators/templates/db/migrate/20091127192645_create_waiting_lists.rb b/db/migrate/20091127192645_create_waiting_lists.rb similarity index 100% rename from lib/generators/templates/db/migrate/20091127192645_create_waiting_lists.rb rename to db/migrate/20091127192645_create_waiting_lists.rb diff --git a/lib/generators/templates/db/migrate/20110406120000_change_waiting_lists_to_stock_requests.rb b/db/migrate/20110406120000_change_waiting_lists_to_stock_requests.rb similarity index 100% rename from lib/generators/templates/db/migrate/20110406120000_change_waiting_lists_to_stock_requests.rb rename to db/migrate/20110406120000_change_waiting_lists_to_stock_requests.rb diff --git a/db/migrate/20141210144427_change_waiting_list_to_spree_waiting_list.rb b/db/migrate/20141210144427_change_waiting_list_to_spree_waiting_list.rb new file mode 100644 index 0000000..507447a --- /dev/null +++ b/db/migrate/20141210144427_change_waiting_list_to_spree_waiting_list.rb @@ -0,0 +1,15 @@ +class ChangeWaitingListToSpreeWaitingList < ActiveRecord::Migration + def self.up + rename_table :stock_requests, :spree_stock_requests + + add_index :spree_stock_requests, :variant_id + add_index :spree_stock_requests, :product_id + end + + def self.down + remove_index :spree_stock_requests, column: :variant_id + remove_index :spree_stock_requests, column: :product_id + + rename_table :spree_stock_requests, :stock_requests + end +end diff --git a/lib/generators/spree_waiting_list/install/install_generator.rb b/lib/generators/spree_waiting_list/install/install_generator.rb new file mode 100644 index 0000000..ec73dde --- /dev/null +++ b/lib/generators/spree_waiting_list/install/install_generator.rb @@ -0,0 +1,31 @@ +module SpreeWaitingList + module Generators + class InstallGenerator < Rails::Generators::Base + + class_option :auto_run_migrations, :type => :boolean, :default => false + + def add_javascripts + # append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_waiting_list\n" + # append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_waiting_list\n" + end + + def add_stylesheets + # inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_waiting_list\n", :before => /\*\//, :verbose => true + # inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_waiting_list\n", :before => /\*\//, :verbose => true + end + + def add_migrations + run 'bundle exec rake railties:install:migrations FROM=spree_waiting_list' + end + + def run_migrations + run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]') + if run_migrations + run 'bundle exec rake db:migrate' + else + puts 'Skipping rake db:migrate, don\'t forget to run it!' + end + end + end + end +end diff --git a/lib/generators/spree_waiting_list/install_generator.rb b/lib/generators/spree_waiting_list/install_generator.rb deleted file mode 100644 index 9c58d7b..0000000 --- a/lib/generators/spree_waiting_list/install_generator.rb +++ /dev/null @@ -1,12 +0,0 @@ -module SpreeWaitingList - module Generators - class InstallGenerator < Rails::Generators::Base - source_root File.expand_path("../../templates", __FILE__) - - desc "Configures your Rails application for use with spree_waiting_list" - def copy_migrations - directory "db" - end - end - end -end diff --git a/lib/spree_waiting_list.rb b/lib/spree_waiting_list.rb index 9e41aa4..6b1b359 100644 --- a/lib/spree_waiting_list.rb +++ b/lib/spree_waiting_list.rb @@ -1,18 +1,3 @@ require 'spree_core' -require 'haml' -require 'spree_waiting_list_hooks' - -module SpreeWaitingList - class Engine < Rails::Engine - - config.autoload_paths += %W(#{config.root}/lib) - - def self.activate - Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c| - Rails.env.production? ? require(c) : load(c) - end - end - - config.to_prepare &method(:activate).to_proc - end -end +require 'spree_waiting_list/engine' +require 'haml' \ No newline at end of file diff --git a/lib/spree_waiting_list/engine.rb b/lib/spree_waiting_list/engine.rb new file mode 100644 index 0000000..f140e05 --- /dev/null +++ b/lib/spree_waiting_list/engine.rb @@ -0,0 +1,21 @@ +module SpreeWaitingList + class Engine < Rails::Engine + require 'spree/core' + isolate_namespace Spree + engine_name 'spree_waiting_list' + + # use rspec for tests + config.generators do |g| + g.test_framework :rspec + end + + def self.activate + Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c| + Rails.configuration.cache_classes ? require(c) : load(c) + end + end + + config.to_prepare &method(:activate).to_proc + + end +end diff --git a/lib/spree_waiting_list/factories.rb b/lib/spree_waiting_list/factories.rb new file mode 100644 index 0000000..65187f4 --- /dev/null +++ b/lib/spree_waiting_list/factories.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + + factory :stock_request, class: Spree::StockRequest do + product + variant {product.master} + email 'test@home.org' + end + +end \ No newline at end of file diff --git a/lib/spree_waiting_list_hooks.rb b/lib/spree_waiting_list_hooks.rb deleted file mode 100644 index 4278c33..0000000 --- a/lib/spree_waiting_list_hooks.rb +++ /dev/null @@ -1,3 +0,0 @@ -class SpreeWaitingListHooks < Spree::ThemeSupport::HookListener - # custom hooks go here -end \ No newline at end of file diff --git a/lib/tasks/install.rake b/lib/tasks/install.rake deleted file mode 100644 index c51fdef..0000000 --- a/lib/tasks/install.rake +++ /dev/null @@ -1,25 +0,0 @@ -namespace :spree_waiting_list do - desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)" - task :install do - Rake::Task['spree_waiting_list:install:migrations'].invoke - Rake::Task['spree_waiting_list:install:assets'].invoke - end - - namespace :install do - desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)" - task :migrations do - source = File.join(File.dirname(__FILE__), '..', '..', 'db') - destination = File.join(Rails.root, 'db') - Spree::FileUtilz.mirror_files(source, destination) - end - - desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)" - task :assets do - source = File.join(File.dirname(__FILE__), '..', '..', 'public') - destination = File.join(Rails.root, 'public') - puts "INFO: Mirroring assets from #{source} to #{destination}" - Spree::FileUtilz.mirror_files(source, destination) - end - end - -end \ No newline at end of file diff --git a/lib/tasks/spree_waiting_list.rake b/lib/tasks/spree_waiting_list.rake deleted file mode 100644 index 2c5c4e2..0000000 --- a/lib/tasks/spree_waiting_list.rake +++ /dev/null @@ -1 +0,0 @@ -# add custom rake tasks here \ No newline at end of file diff --git a/spec/controllers/spree/stock_requests_controller_spec.rb b/spec/controllers/spree/stock_requests_controller_spec.rb new file mode 100644 index 0000000..7321530 --- /dev/null +++ b/spec/controllers/spree/stock_requests_controller_spec.rb @@ -0,0 +1,86 @@ +require 'spec_helper' + +module Spree + + describe StockRequestsController do + + let(:user) {create(:user_with_addreses)} + let!(:product) {create(:product)} + + before do + controller.stub :try_spree_current_user => nil + end + + it '#new' do + + spree_get :new, stock_request: { product_id: product.id} + + expect(response).to be_success + + end + + context '#create' do + + context 'valid data' do + + USER_MAIL = 'user@gmail.com' + + it 'html format' do + spree_post :create, :stock_request => { email: USER_MAIL, product_id: product.id, variant_id: product.master.id} + + expect(response).to redirect_to(spree.root_path) + expect(flash[:notice]).to eql(Spree.t(:successful_stock_request)) + expect(Spree::StockRequest.where(email: USER_MAIL).first).to_not be_nil + + end + + it 'js format' do + + spree_post :create, {:stock_request => { email: USER_MAIL, product_id: product.id, variant_id: product.master.id}, :format => :js} + + expect(response).to be_success + expect(response).to render_template('create') + + end + + context 'logged in' do + + before do + controller.stub :try_spree_current_user => user + end + + it 'should set email' do + spree_post :create, stock_request: {product_id: product.id, variant_id: product.master.id} + + expect(Spree::StockRequest.where(email: user.email).first).to_not be_nil + end + end + + end + + context 'invalid data' do + + it 'raises an exception' do + expect { spree_post :create }.to raise_error ActionController::ParameterMissing + end + + context 'show messages validation' do + + it 'html format' do + spree_post :create, stock_request: {email: 'user'} + + expect(response).to render_template('new') + end + + it 'js format' do + spree_xhr_post :create, {:stock_request => {email: 'user'}} + + expect(response.status).to eql(Rack::Utils::SYMBOL_TO_STATUS_CODE[:unprocessable_entity]) + end + end + end + end + end + +end + diff --git a/spec/controllers/stock_requests_controller_spec.rb b/spec/controllers/stock_requests_controller_spec.rb deleted file mode 100644 index f5ae615..0000000 --- a/spec/controllers/stock_requests_controller_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper' - -describe StockRequestsController do - context "GET /new" do - before do - StockRequest.should_receive(:new).and_return(:request) - get :new - end - - specify { assigns(:stock_request).should == :request } - specify { response.should be_success } - end - - context "POST /create" do - context "valid data" do - let(:request) { mock_model(StockRequest, :save => true) } - - before do - StockRequest.should_receive(:new).with(:data).and_return(request) - end - - context "html format" do - before { post :create, :stock_request => :data } - - specify { response.should redirect_to(root_path) } - specify { flash[:notice].should == I18n.t(:successful_stock_request) } - end - - context "js format" do - before { xhr :post, :create, :stock_request => :data } - - specify { response.should be_success } - specify { response.should render_template('create') } - end - - context "logged in" do - let(:user) { create_user } - - it "should set email" do - request.should_receive(:email=).with(user.email) - sign_in user - post :create, :stock_request => :data - end - end - end - - - context "invalid data" do - let(:request) { mock_model(StockRequest, :save => false) } - - before do - StockRequest.should_receive(:new).with(:data).and_return(request) - post :create, :stock_request => :data - end - - specify { assigns(:stock_request).should == request } - specify { response.should be_success } - specify { response.should render_template('new') } - end - end -end diff --git a/spec/mailers/spree/user_mailer_spec.rb b/spec/mailers/spree/user_mailer_spec.rb new file mode 100644 index 0000000..47e422d --- /dev/null +++ b/spec/mailers/spree/user_mailer_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +module Spree + + describe UserMailer do + + USER_EMAIL = 'admin@mysite.com' + + let(:request) { create(:stock_request) } + + before do + Spree.config {|config| config.mails_from = USER_EMAIL } + end + + it 'back in stock' do + + @mail = UserMailer.back_in_stock(request) + + expect(@mail.subject).to eql(Spree.t(:back_in_stock_subject, product_name: request.product.name)) + expect(@mail.to).to include(request.email) + expect(@mail.from).to include(USER_EMAIL) + + end + + end +end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb deleted file mode 100644 index d8b51db..0000000 --- a/spec/mailers/user_mailer_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe UserMailer do - context "back in stock" do - let(:request) { mock_model(StockRequest, - :email => 'test@123.com', - :variant => nil, - :product => mock_model(Product, :name => 'Widget')) } - before do - Spree::Config.set :order_from => 'admin@mysite.com' - @mail = UserMailer.back_in_stock(request) - end - - specify { @mail.subject.should == "Hey! Widget is back in stock" } - specify { @mail.to.should include("test@123.com") } - specify { @mail.from.should include("admin@mysite.com") } - - end -end diff --git a/spec/models/spree/stock_request_spec.rb b/spec/models/spree/stock_request_spec.rb new file mode 100644 index 0000000..29259df --- /dev/null +++ b/spec/models/spree/stock_request_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +module Spree + + describe StockRequest do + + subject { create(:stock_request) } + + it { expect(subject).to be_valid } + it { subject.status.should == 'new' } + + it 'should validate email' do + subject.email = 'garbage' + subject.valid? + + expect(subject.errors[:email].size).to eq(1) + end + + context 'notification' do + + before do + mail = double(:mail) + UserMailer.should_receive(:back_in_stock).with(subject).and_return(mail) + mail.should_receive(:deliver) + subject.notify! + end + + it { expect(subject.status).to eql('notified') } + it { expect(StockRequest.notified(false).size).to eq(0) } + it { expect(StockRequest.notified(true).size).to eq(1) } + end + + end + +end + diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb new file mode 100644 index 0000000..62bd237 --- /dev/null +++ b/spec/models/spree/variant_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +module Spree + + describe Variant do + + end + +end diff --git a/spec/models/stock_request_spec.rb b/spec/models/stock_request_spec.rb deleted file mode 100644 index f3179a0..0000000 --- a/spec/models/stock_request_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require File.dirname(__FILE__) + '/../spec_helper' - -describe StockRequest do - - specify { create_stock_request.should be_valid } - specify { create_stock_request(:email => 'garbage').should have(1).error_on(:email) } - specify { create_stock_request.status.should == 'new' } - - context "notification" do - before do - mail = mock(:mail) - @request = create_stock_request - UserMailer.should_receive(:back_in_stock).with(@request).and_return(mail) - mail.should_receive(:deliver) - @request.notify! - end - - specify { @request.status.should == 'notified' } - specify { StockRequest.notified(false).should have(0).stock_requests } - specify { StockRequest.notified(true).should have(1).stock_requests } - end - - def create_stock_request(fields={}) - StockRequest.create({:variant_id => 1, :product_id => 1, :email => 'test@home.org'}.merge(fields)) - end -end diff --git a/spec/models/variant_spec.rb b/spec/models/variant_spec.rb deleted file mode 100644 index 4635716..0000000 --- a/spec/models/variant_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'spec_helper' - -describe Variant do -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a252978..259285e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,50 @@ -# This file is copied to ~/spec when you run 'ruby script/generate rspec' -# from the project root directory. -ENV["RAILS_ENV"] ||= 'test' -require File.expand_path("../test_app/config/environment", __FILE__) +# Run Coverage report +require 'simplecov' +SimpleCov.start do + add_filter 'spec/dummy' + add_group 'Controllers', 'app/controllers' + add_group 'Helpers', 'app/helpers' + add_group 'Mailers', 'app/mailers' + add_group 'Models', 'app/models' + add_group 'Views', 'app/views' + add_group 'Libraries', 'lib' +end + +# Configure Rails Environment +ENV['RAILS_ENV'] = 'test' + +require File.expand_path('../dummy/config/environment.rb', __FILE__) + require 'rspec/rails' +require 'database_cleaner' +require 'ffaker' -# Requires supporting files with custom matchers and macros, etc, -# in ./support/ and its subdirectories. -Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f } + +# Requires factories defined in spree_core +require 'spree/testing_support/factories' +require 'spree/testing_support/controller_requests' +require 'spree/testing_support/authorization_helpers' +require 'spree/testing_support/url_helpers' + +# Requires factories defined in lib/spree_simple_teste/factories.rb +require 'spree_waiting_list/factories' RSpec.configure do |config| + config.include FactoryGirl::Syntax::Methods + + # == URL Helpers + # + # Allows access to Spree's routes in specs: + # + # visit spree.admin_path + # current_path.should eql(spree.products_path) + config.include Spree::TestingSupport::UrlHelpers + config.include Spree::TestingSupport::AuthorizationHelpers::Controller + config.include Spree::TestingSupport::ControllerRequests + # == Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: @@ -17,21 +53,41 @@ # config.mock_with :flexmock # config.mock_with :rr config.mock_with :rspec + config.color = true + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#{::Rails.root}/spec/fixtures" - #config.include Devise::TestHelpers, :type => :controller - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, comment the following line or assign false - # instead of true. - config.use_transactional_fixtures = true + # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner + # to cleanup after each test instead. Without transactional fixtures set to false the records created + # to setup a test will be unavailable to the browser, which runs under a separate server instance. + config.use_transactional_fixtures = false - config.include Devise::TestHelpers, :type => :controller -end + config.infer_spec_type_from_file_location! + + config.raise_errors_for_deprecations! + + # Ensure Suite is set to use transactions for speed. + config.before :suite do + DatabaseCleaner.strategy = :transaction + DatabaseCleaner.clean_with :truncation + end + + # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary. + config.before :each do + DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction + DatabaseCleaner.start + end -@createconfiguration ||= AppConfiguration.find_or_create_by_name("Default configuration") + # After each spec clean the database. + config.after :each do + DatabaseCleaner.clean + end -def create_user - User.create(:confirmed => true, :password => 'test123', :password_confirmation => 'test123', :email => 'john@example.com') + config.fail_fast = ENV['FAIL_FAST'] || false + config.order = "random" end +# def create_user +# User.create(:confirmed => true, :password => 'test123', :password_confirmation => 'test123', :email => 'john@example.com') +# end \ No newline at end of file diff --git a/spree_waiting_list.gemspec b/spree_waiting_list.gemspec index 2d405b4..48415f3 100644 --- a/spree_waiting_list.gemspec +++ b/spree_waiting_list.gemspec @@ -1,10 +1,10 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'spree_waiting_list' - s.version = '0.3.0' + s.version = '1.0.0' s.summary = 'Add a waiting list to your spree store' s.description = 'The waiting list allows users to signup to be notified via email when an items comes back into stock' - s.required_ruby_version = '>= 1.8.7' + s.required_ruby_version = '>= 1.9.3' s.author = 'Joshua Nussbaum' s.email = 'joshnuss@gmail.com' @@ -16,6 +16,17 @@ Gem::Specification.new do |s| s.has_rdoc = false - s.add_dependency('spree_core', '>= 0.70.0') - s.add_dependency('haml', '> 0') + s.add_dependency 'spree_core', '~> 2.2.2' + s.add_dependency 'haml', '~> 4.0.6' + + s.add_development_dependency 'capybara', '~> 2.1' + s.add_development_dependency 'coffee-rails' + s.add_development_dependency 'database_cleaner' + s.add_development_dependency 'factory_girl', '~> 4.4' + s.add_development_dependency 'ffaker' + s.add_development_dependency 'rspec-rails', '~> 2.13' + s.add_development_dependency 'sass-rails' + s.add_development_dependency 'selenium-webdriver' + s.add_development_dependency 'simplecov' + s.add_development_dependency 'sqlite3' end