Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update file structure to look like latest gem style

  • Loading branch information...
commit f30c6006b56d6088268c41075ca2038c4c443f1d 1 parent 27e5b36
@joshnuss authored
View
2  .gitignore
@@ -4,7 +4,7 @@
.DS_Store
tmp
*.swp
-spec/test_app
+spec/dummy
Gemfile
Gemfile.lock
pkg
View
10 Guardfile
@@ -0,0 +1,10 @@
+guard 'rspec', :cli => '--color --format doc' do
+ watch('spec/spec_helper.rb') { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+end
View
61 Rakefile
@@ -1,12 +1,19 @@
-require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
-require 'rake/gempackagetask'
+require 'rubygems/package_task'
+require 'rspec/core/rake_task'
+require 'cucumber/rake/task'
+require 'spree_core/testing_support/common_rake'
+
+RSpec::Core::RakeTask.new
+Cucumber::Rake::Task.new
+
+task :default => [:spec, :cucumber ]
spec = eval(File.read('spree_contact_form.gemspec'))
-Rake::GemPackageTask.new(spec) do |p|
+Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end
@@ -17,50 +24,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 "Regenerates a rails 3 app for testing"
+desc "Generates a dummy 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_contact_form', :path => '../..'
- gems
- end
- end
-
- def install_gems
- system("cd spec/test_app && rake spree_core:install")
- system("cd spec/test_app && rake spree_auth:install")
- generate 'spree_contact_form:install'
- end
-
- def migrate_db
- run_migrations
- end
- end
- AuthTestAppGenerator.start
+ ENV['LIB_NAME'] = 'spree_contact_form'
+ Rake::Task['common:test_app'].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")
- end
-end
-
View
5 app/overrides/admin.rb
@@ -0,0 +1,5 @@
+Deface::Override.new(:virtual_path => "admin/configurations/index",
+ :name => "converted_admin_configurations_menu_394888068",
+ :insert_after => "[data-hook='admin_configurations_menu'], #admin_configurations_menu[data-hook]",
+ :text => "<%= configurations_menu_item(I18n.t('contact_topics'), admin_contact_topics_path, I18n.t('contact_topics_description')) %>",
+ :disabled => false)
View
4 app/views/admin/contact_topics/_form.html.erb
@@ -2,7 +2,7 @@
<%= render "shared/error_messages", :target => f.object %>
-<%= hook :admin_contact_topic_form, locals do %>
+<div data-hook="admin_contact_topic_form">
<%= f.field_container :name do %>
<%= f.label :name, t("name") %> <span class="required">*</span><br />
@@ -16,4 +16,4 @@
<%= f.error_message_on :emails %>
<% end %>
-<% end %>
+</div>
View
31 app/views/admin/contact_topics/index.html.erb
@@ -12,28 +12,21 @@
<div id="new_contact_topic"></div>
<table class="index">
- <tr>
- <%= hook :admin_contact_topic_index_headers do %>
- <th><%= t("name") %></th>
- <th><%= t("emails") %></th>
- <% end %>
- <th>
- <%= hook :admin_contact_topic_index_header_actions %>
+ <tr data-hook='admin_contact_topic_index_headers'>
+ <th><%= t("name") %></th>
+ <th><%= t("emails") %></th>
+ <th data-hook='admin_contact_topic_index_header_actions'>
</th>
</tr>
<% @contact_topics.each do |topic| %>
- <tr id="<%= dom_id topic %>">
- <%- locals = {:topic => topic} %>
- <%= hook :admin_contact_topics_index_rows, locals do %>
- <td><%= topic.name %></td>
- <td><%= topic.emails %></td>
- <% end %>
- <td class="actions">
- <%= hook :admin_contact_topics_index_row_actions, locals do %>
- <%= link_to_edit topic %>
- &nbsp;
- <%= link_to_delete topic %>
- <% end %>
+ <%- locals = {:topic => topic} %>
+ <tr id="<%= dom_id topic %>" data-hook="admin_contact_topics_index_rows">
+ <td><%= topic.name %></td>
+ <td><%= topic.emails %></td>
+ <td class="actions" data-hook="admin_contact_topic_index_header_actions">
+ <%= link_to_edit topic %>
+ &nbsp;
+ <%= link_to_delete topic %>
</td>
</tr>
<% end %>
View
14 app/views/contact/show.html.erb
@@ -4,14 +4,12 @@
<div id="contact-us">
<h1><%= t("contact_us") %></h1>
- <%= hook :contact do %>
-
+ <div data-hook='contact'>
<%= render "shared/error_messages", :target => @message %>
<%= form_for(:message, :url => contact_path) do |f| %>
- <%= hook :contact_inside_form do %>
-
+ <div data-hook="contact_inside_form">
<p>
<%= f.label :topic_id, t("subject") %><br />
<%= f.collection_select :topic_id, @topics, :id, :name %>
@@ -38,11 +36,7 @@
</p>
<p><%= submit_tag t("send_message"), :class => 'button primary' %></p>
- <% end %>
-
+ </div>
<% end %>
-
- <% end %>
-
+ </div>
</div>
-
View
29 lib/generators/spree_contact_form/install/install_generator.rb
@@ -0,0 +1,29 @@
+module SpreeContactForm
+ module Generators
+ class InstallGenerator < Rails::Generators::Base
+
+ def add_javascripts
+ append_file "app/assets/javascripts/store/all.js", "//= require store/spree_contact_form\n"
+ append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_contact_form\n"
+ end
+
+ def add_stylesheets
+ inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_contact_form\n", :before => /\*\//, :verbose => true
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_contact_form\n", :before => /\*\//, :verbose => true
+ end
+
+ def add_migrations
+ run 'bundle exec rake railties:install:migrations FROM=spree_contact_form'
+ 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
View
1  lib/spree_contact_form.rb
@@ -1,3 +1,2 @@
require 'spree_core'
-require 'spree_contact_form_hooks'
require 'spree_contact_form/engine'
View
18 lib/spree_contact_form/engine.rb
@@ -1,12 +1,26 @@
require "spree_contact_form"
module SpreeContactForm
-
class Engine < Rails::Engine
+ engine_name 'spree_contact_form'
+
+ 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
View
7 lib/spree_contact_form_hooks.rb
@@ -1,7 +0,0 @@
-class SpreeContactFormHooks < Spree::ThemeSupport::HookListener
- insert_after :admin_configurations_menu do
- "<%= configurations_menu_item(I18n.t('contact_topics'), admin_contact_topics_path, I18n.t('contact_topics_description')) %>"
- end
-
-end
-
View
2  spec/controllers/contact_controller_spec.rb
@@ -42,7 +42,7 @@
describe "when data is valid" do
it "should send email" do
message, mail = mock(:message, :save => true), mock(:mail)
- Message.should_receive(:new).with(:message_params).and_return(message)
+ Message.should_receive(:new).with('message_params').and_return(message)
ContactMailer.should_receive(:message_email).with(message).and_return(mail)
mail.should_receive(:deliver)
View
19 spec/spec_helper.rb
@@ -1,12 +1,13 @@
-# 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__)
+# Configure Rails Environment
+ENV["RAILS_ENV"] = "test"
+require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'
-# 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[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+require 'spree_core/testing_support/factories'
RSpec.configure do |config|
# == Mock Framework
@@ -18,11 +19,11 @@
# 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, comment the following line or assign false
+ # examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
end
-
View
2  spree_contact_form.gemspec
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_contact_form'
- s.version = '3.0.5'
+ s.version = '3.0.6'
s.summary = 'Adds a contact form for your spree site'
s.description = 'Add a contact form for your spree website, you can setup topics and when the user submits the form, it is emailed to the site admin'
s.required_ruby_version = '>= 1.8.7'
Please sign in to comment.
Something went wrong with that request. Please try again.