forked from spree-contrib/spree_comments
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Trung Lê
committed
Sep 21, 2011
1 parent
82cc21a
commit 3c524f9
Showing
20 changed files
with
169 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<li <%= raw ' class="active"' if (defined? current and current == 'Comments') %>> | ||
<li <%== ' class="active"' if (defined? current and current == 'Comments') %>> | ||
<%= link_to t(:comments), comments_admin_order_url(@order) %> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<li> | ||
<%= button_link_to(t(:comments), comments_admin_order_shipment_url(@order, @shipment)) %> | ||
<%= button_link_to t(:comments), comments_admin_order_shipment_url(@order, @shipment) %> | ||
</li> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
lib/generators/spree_comments/install/install_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.