diff --git a/Gemfile b/Gemfile deleted file mode 100644 index cd4a9e6..0000000 --- a/Gemfile +++ /dev/null @@ -1,32 +0,0 @@ -source 'http://rubygems.org' - -gem 'sqlite3-ruby', :require => 'sqlite3' - -group :test do - gem 'rspec-rails', '= 2.4.1' - gem 'factory_girl_rails' - gem 'rcov' - gem 'shoulda' - gem 'faker' - if RUBY_VERSION < "1.9" - gem "ruby-debug" - else - gem "ruby-debug19" - end -end - -group :cucumber do - gem 'cucumber-rails' - gem 'database_cleaner', '~> 0.5.2' - gem 'nokogiri' - gem 'capybara' - gem 'factory_girl_rails' - gem 'faker' - gem 'launchy' - - if RUBY_VERSION < "1.9" - gem "ruby-debug" - else - gem "ruby-debug19" - end -end diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3af27df --- /dev/null +++ b/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2011 Rails Dog +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name Spree nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.markdown b/README.md similarity index 85% rename from README.markdown rename to README.md index f687530..9e460ec 100644 --- a/README.markdown +++ b/README.md @@ -1,4 +1,5 @@ -# Spree Comments +Spree Comments +============== Spree Comments is an extension for Spree to allow commenting on different models via the admin ui and currently supports Orders & Shipments. @@ -25,17 +26,17 @@ Add the following to your Gemfile gem "spree_comments" gem "acts_as_commentable" -Run: - +Run: + bundle install Copy over migrations via the rake task: - rake spree_comments:install + bundle exec rake railties:install:migrations FROM=spree_comments Run the migrations: - rake db:migrate + bundle exec rake db:migrate Start your server: diff --git a/Rakefile b/Rakefile index 88c1ab6..65a12bd 100644 --- a/Rakefile +++ b/Rakefile @@ -1,69 +1,31 @@ -# encoding: utf-8 -require 'rubygems' require 'rake' require 'rake/testtask' +require 'rake/packagetask' +require 'rubygems/package_task' +require 'rspec/core/rake_task' +require 'cucumber/rake/task' +require 'spree_core/testing_support/common_rake' -desc "Default Task" -task :default => [ :spec ] +RSpec::Core::RakeTask.new +Cucumber::Rake::Task.new -gemfile = File.expand_path('../spec/test_app/Gemfile', __FILE__) -if File.exists?(gemfile) && %w(rcov spec cucumber).include?(ARGV.first.to_s) - require 'bundler' - ENV['BUNDLE_GEMFILE'] = gemfile - Bundler.setup +task :default => [:spec, :cucumber ] - 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 "Run specs with RCov" - RSpec::Core::RakeTask.new(:rcov) do |t| - t.rcov = true - t.rcov_opts = %w{ --exclude gems\/,spec\/,features\/} - t.verbose = true - end +spec = eval(File.read('spree_comments.gemspec')) +Gem::PackageTask.new(spec) do |p| + p.gem_spec = spec 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 AuthTestAppGenerator < 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_comments', :path => '#{File.dirname(__FILE__)}' -gems - end - end - - def install_gems - inside "test_app" do - run 'rake spree_core:install' - run 'rake spree_auth:install' - run 'rake spree_comments:install' - end - end - - def migrate_db - run_migrations - end - end - AuthTestAppGenerator.start +desc "Release to gemcutter" +task :release => :package do + require 'rake/gemcutter' + Rake::Gemcutter::Tasks.new(spec).define + Rake::Task['gem:push'].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_comments' + Rake::Task['common:test_app'].invoke end - diff --git a/app/overrides/add_comment_configuration.rb b/app/overrides/add_comment_configuration.rb new file mode 100644 index 0000000..cca0587 --- /dev/null +++ b/app/overrides/add_comment_configuration.rb @@ -0,0 +1,5 @@ +Deface::Override.new(:virtual_path => "admin/configurations/index", + :name => "converted_admin_configurations_menu_468573024", + :insert_after => "[data-hook='admin_configurations_menu'], #admin_configurations_menu[data-hook]", + :text => "<%= configurations_menu_item(I18n.t('comment_types'), admin_comment_types_url, I18n.t('manage_comment_types')) %>", + :disabled => false) \ No newline at end of file diff --git a/app/overrides/add_comment_to_admin_orders_tabs.rb b/app/overrides/add_comment_to_admin_orders_tabs.rb new file mode 100644 index 0000000..0e0466e --- /dev/null +++ b/app/overrides/add_comment_to_admin_orders_tabs.rb @@ -0,0 +1,5 @@ +Deface::Override.new(:virtual_path => "admin/shared/_order_tabs", + :name => "converted_admin_order_tabs_472794197", + :insert_bottom => "[data-hook='admin_order_tabs'], #admin_order_tabs[data-hook]", + :partial => "admin/orders/tab", + :disabled => false) \ No newline at end of file diff --git a/app/overrides/add_shipment_comment_button.rb b/app/overrides/add_shipment_comment_button.rb new file mode 100644 index 0000000..4ac5a24 --- /dev/null +++ b/app/overrides/add_shipment_comment_button.rb @@ -0,0 +1,5 @@ +Deface::Override.new(:virtual_path => "admin/shipments/edit", + :name => "converted_admin_shipment_edit_buttons_233418828", + :insert_after => "[data-hook='admin_shipment_edit_buttons'], #admin_shipment_edit_buttons[data-hook]", + :partial => "admin/shipments/button", + :disabled => false) \ No newline at end of file diff --git a/app/views/admin/orders/_tab.html.erb b/app/views/admin/orders/_tab.html.erb index c652a0d..dc96e03 100644 --- a/app/views/admin/orders/_tab.html.erb +++ b/app/views/admin/orders/_tab.html.erb @@ -1,3 +1,3 @@ -
  • > +
  • > <%= link_to t(:comments), comments_admin_order_url(@order) %>
  • diff --git a/app/views/admin/shared/_comment_list.html.erb b/app/views/admin/shared/_comment_list.html.erb index a35fea4..946eb71 100644 --- a/app/views/admin/shared/_comment_list.html.erb +++ b/app/views/admin/shared/_comment_list.html.erb @@ -1,6 +1,6 @@ - + <% if @comment_types and !@comment_types.empty? %> <% end %> diff --git a/app/views/admin/shipments/_button.html.erb b/app/views/admin/shipments/_button.html.erb index db6b0c8..1a451e5 100644 --- a/app/views/admin/shipments/_button.html.erb +++ b/app/views/admin/shipments/_button.html.erb @@ -1,4 +1,4 @@
  • - <%= button_link_to(t(:comments), comments_admin_order_shipment_url(@order, @shipment)) %> + <%= button_link_to t(:comments), comments_admin_order_shipment_url(@order, @shipment) %>
  • diff --git a/db/migrate/20091021182639_create_comments.rb b/db/migrate/20091021182639_create_comments.rb index 38a7543..70dcd34 100644 --- a/db/migrate/20091021182639_create_comments.rb +++ b/db/migrate/20091021182639_create_comments.rb @@ -5,6 +5,7 @@ def self.up t.text :comment, :default => "" t.references :commentable, :polymorphic => true t.references :user + t.timestamps end diff --git a/db/migrate/20100406085611_create_comment_types.rb b/db/migrate/20100406085611_create_comment_types.rb index dc5e8ed..1a6dd0e 100644 --- a/db/migrate/20100406085611_create_comment_types.rb +++ b/db/migrate/20100406085611_create_comment_types.rb @@ -3,6 +3,7 @@ def self.up create_table :comment_types do |t| t.string :name t.string :applies_to + t.timestamps end end diff --git a/lib/generators/spree_comments/install/install_generator.rb b/lib/generators/spree_comments/install/install_generator.rb new file mode 100644 index 0000000..8beda1c --- /dev/null +++ b/lib/generators/spree_comments/install/install_generator.rb @@ -0,0 +1,19 @@ +module SpreeComments + module Generators + class InstallGenerator < Rails::Generators::Base + + def add_migrations + run 'bundle exec rake railties:install:migrations FROM=spree_comments' + end + + def run_migrations + res = ask "Would you like to run the migrations now? [Y/n]" + if res == "" || res.downcase == "y" + run 'bundle exec rake db:migrate' + else + puts "Skiping rake db:migrate, don't forget to run it!" + end + end + end + end +end diff --git a/lib/spree_comments.rb b/lib/spree_comments.rb index c9b441e..ca2a670 100644 --- a/lib/spree_comments.rb +++ b/lib/spree_comments.rb @@ -1,18 +1,3 @@ require 'spree_core' require 'acts_as_commentable' -require 'spree_comments_hooks' - -module SpreeComments - 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_comments/engine' \ No newline at end of file diff --git a/lib/spree_comments/engine.rb b/lib/spree_comments/engine.rb new file mode 100644 index 0000000..9b54cec --- /dev/null +++ b/lib/spree_comments/engine.rb @@ -0,0 +1,25 @@ +module SpreeComments + class Engine < Rails::Engine + engine_name 'spree_comments' + + config.autoload_paths += %W(#{config.root}/lib) + + # 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.application.config.cache_classes ? require(c) : load(c) + end + + Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c| + Rails.application.config.cache_classes ? require(c) : load(c) + end + end + + config.to_prepare &method(:activate).to_proc + end +end + diff --git a/lib/spree_comments_hooks.rb b/lib/spree_comments_hooks.rb deleted file mode 100644 index e3f3253..0000000 --- a/lib/spree_comments_hooks.rb +++ /dev/null @@ -1,19 +0,0 @@ -class SpreeCommentsHooks < Spree::ThemeSupport::HookListener - Deface::Override.new(:virtual_path => "admin/shared/_order_tabs", - :name => "converted_admin_order_tabs_472794197", - :insert_bottom => "[data-hook='admin_order_tabs'], #admin_order_tabs[data-hook]", - :partial => "admin/orders/tab", - :disabled => false) - - Deface::Override.new(:virtual_path => "admin/shipments/edit", - :name => "converted_admin_shipment_edit_buttons_233418828", - :insert_after => "[data-hook='admin_shipment_edit_buttons'], #admin_shipment_edit_buttons[data-hook]", - :partial => "admin/shipments/button", - :disabled => false) - - Deface::Override.new(:virtual_path => "admin/configurations/index", - :name => "converted_admin_configurations_menu_468573024", - :insert_after => "[data-hook='admin_configurations_menu'], #admin_configurations_menu[data-hook]", - :text => "<%= configurations_menu_item(I18n.t('comment_types'), admin_comment_types_url, I18n.t('manage_comment_types')) %>", - :disabled => false) -end diff --git a/lib/tasks/install.rake b/lib/tasks/install.rake deleted file mode 100644 index 941444c..0000000 --- a/lib/tasks/install.rake +++ /dev/null @@ -1,15 +0,0 @@ -namespace :spree_comments do - desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)" - task :install do - Rake::Task['spree_comments:install:migrations'].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 - end -end diff --git a/script/rails b/script/rails new file mode 100644 index 0000000..ef2a53b --- /dev/null +++ b/script/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + + +ENGINE_PATH = File.expand_path('../..', __FILE__) +APP_PATH = File.expand_path('../../../config/application', __FILE__) +require File.expand_path('../../../config/boot', __FILE__) +require 'rails/commands' + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..cc1bc1c --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,31 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + + +require File.expand_path("../../../config/environment.rb", __FILE__) + + +require 'rspec/rails' + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +RSpec.configure do |config| + # == Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + config.mock_with :rspec + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # 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 +end diff --git a/spree_comments.gemspec b/spree_comments.gemspec index 45555b4..21b31a0 100644 --- a/spree_comments.gemspec +++ b/spree_comments.gemspec @@ -1,17 +1,22 @@ +# encoding: UTF-8 Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'spree_comments' - s.version = '1.0.0' + s.version = '1.0.1' s.summary = 'Comments for orders and shipments' - s.homepage = 'https://github.com/spree/spree_comments' + s.required_ruby_version = '>= 1.8.7' + s.author = 'Rails Dog' s.email = 'gems@railsdog.com' - s.required_ruby_version = '>= 1.8.7' + s.homepage = 'https://github.com/spree/spree_comments' s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.require_paths = ["lib"] + s.require_path = 'lib' + s.requirements << 'none' + + s.add_dependency 'spree_core', '>= 0.70.RC1' + s.add_dependency 'acts_as_commentable', '3.0.0' + s.add_development_dependency 'rspec-rails' - s.add_dependency('spree_core', '>=0.60.1') - s.add_dependency('acts_as_commentable', '3.0.0') -end +end \ No newline at end of file
    <%= "#{I18n::t('spree.date')}/#{I18n::t('spree.time')}" %><%= "#{t('spree.date')}/#{t('spree.time')}" %><%= t(:type) %>