Skip to content

Commit

Permalink
clean commit of PR joshmcarthur#17 with 1_1_X
Browse files Browse the repository at this point in the history
  • Loading branch information
sbounmy committed Mar 27, 2012
1 parent 25bc3ff commit 9553240
Show file tree
Hide file tree
Showing 28 changed files with 827 additions and 409 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
tmp
nbproject
*.swp
.rvmrc
Gemfile.lock
.bundle
spec/dummy
17 changes: 16 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
source "http://rubygems.org"
source 'http://rubygems.org'

group :test do

This comment has been minimized.

Copy link
@joshmcarthur

joshmcarthur Mar 27, 2012

Hey @sbounmy,

I'd prefer these gems to be in the gemspec, using add_development_dependency - this keeps the Gemfile clean, and makes sure all the gem dependencies are listed in one place.

gem 'ffaker'
gem 'rspec-rails'
gem 'capybara'
gem 'launchy', '2.0.5'
gem 'factory_girl'
end

if RUBY_VERSION < "1.9"
gem "ruby-debug"
else
gem "ruby-debug19"
end

gemspec
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,16 @@ All the configuration for this extension is inside the initializer generated whe
In most cases, it's unlikely you will need to change defaults, but it's there is you need it.


TODOs
==============
Ttttteeeessssttttiiinnnggg!!
TESTING
=======

```ruby
rake test_app
cd spec/dummy
rake db:create
rake db:migrate db:test:prepare
rails generate delayed_job:active_record
```

INSTALLATION
==============
Expand Down
28 changes: 13 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require File.expand_path('../../config/application', __FILE__)

require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
require 'spree/core/testing_support/common_rake'

RSpec::Core::RakeTask.new

task :default => [:spec]

spec = eval(File.read('import_products.gemspec'))

Rake::GemPackageTask.new(spec) do |p|
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end

Expand All @@ -19,13 +22,8 @@ task :release => :package do
Rake::Task['gem:push'].invoke
end

desc "Default Task"
task :default => [ :spec ]

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new

# require 'cucumber/rake/task'
# Cucumber::Rake::Task.new do |t|
# t.cucumber_opts = %w{--format pretty}
# end
desc "Generates a dummy app for testing"
task :test_app do
ENV['LIB_NAME'] = 'import_products'
Rake::Task['common:test_app'].invoke
end
46 changes: 27 additions & 19 deletions app/controllers/spree/admin/product_imports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
module Spree
module Admin
class ProductImportsController < BaseController
module Admin
class ProductImportsController < BaseController

#Sorry for not using resource_controller railsdog - I wanted to, but then... I did it this way.
#Verbosity is nice?
#Feel free to refactor and submit a pull request.
#Sorry for not using resource_controller railsdog - I wanted to, but then... I did it this way.
#Verbosity is nice?
#Feel free to refactor and submit a pull request.

def index
redirect_to :action => :new
end
def index
@product_import = ProductImport.new
end

def new
@product_import = ProductImport.new
end
def show
@product_import = ProductImport.find(params[:id])
@products = @product_import.products
end

def create
@product_import = ProductImport.create(params[:product_import])
Delayed::Job.enqueue ImportProducts::ImportJob.new(@product_import, @current_user)
flash[:notice] = t('product_import_processing')
redirect_to admin_product_imports_path
end

def create
@product_import = ProductImport.create(params[:product_import])
Delayed::Job.enqueue ImportProducts::ImportJob.new(@product_import, @current_user)
flash[:notice] = t('product_import_processing')
redirect_to admin_product_imports_path
end
end
end
def destroy
@product_import = ProductImport.find(params[:id])
if @product_import.destroy
flash[:notice] = t('delete_product_import_successful')
end
redirect_to admin_product_imports_path
end
end
end
end
23 changes: 23 additions & 0 deletions app/helpers/spree/admin/navigation_helper_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# TODO Remove this fix once this pull request is merged and bumped: https://github.com/spree/spree/pull/1308
Spree::Admin::NavigationHelper.module_eval do
def button(text, icon_name = nil, button_type = 'submit', options={})
button_tag(content_tag('span', icon(icon_name) + ' ' + text), options.merge(:type => button_type))
end

def button_link_to(text, url, html_options = {})
if (html_options[:method] &&
html_options[:method].to_s.downcase != 'get' &&
!html_options[:remote])
form_tag(url, :method => html_options.delete(:method)) do
button(text, html_options.delete(:icon), nil, html_options)
end
else
if html_options['data-update'].nil? && html_options[:remote]
object_name, action = url.split('/')[-2..-1]
html_options['data-update'] = [action, object_name.singularize].join('_')
end
html_options.delete('data-update') unless html_options['data-update']
link_to(text_for_button_link(text, html_options), url, html_options_for_button_link(html_options))
end
end
end
Loading

0 comments on commit 9553240

Please sign in to comment.