-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move images backend into a generator.
* Added cucumber coverage for generators using aruba * Removed images backend from engine * Removed paperclip dependency from gem spec
- Loading branch information
Showing
17 changed files
with
192 additions
and
66 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 |
---|---|---|
@@ -1,2 +1,15 @@ | ||
source 'http://rubygems.org' | ||
|
||
#Dependencies for the dummy app | ||
gem 'jquery-rails' | ||
gem 'sqlite3' | ||
|
||
# Gems used only for assets and not required | ||
# in production environments by default. | ||
group :assets do | ||
gem 'sass-rails' | ||
gem 'coffee-rails' | ||
gem 'uglifier' | ||
end | ||
|
||
gemspec |
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,13 +1,9 @@ | ||
Mercury::Engine.routes.draw do | ||
match '/editor(/*requested_uri)' => "mercury#edit", :as => :mercury_editor | ||
match '/editor(/*requested_uri)' => "mercury#edit", :as => :mercury_editor | ||
|
||
namespace :mercury do | ||
resources :images | ||
end | ||
|
||
scope '/mercury' do | ||
match ':type/:resource' => "mercury#resource" | ||
match 'snippets/:name/options' => "mercury#snippet_options" | ||
match 'snippets/:name/preview' => "mercury#snippet_preview" | ||
end | ||
scope '/mercury' do | ||
match ':type/:resource' => "mercury#resource" | ||
match 'snippets/:name/options' => "mercury#snippet_options" | ||
match 'snippets/:name/preview' => "mercury#snippet_preview" | ||
end | ||
end |
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,63 @@ | ||
@announce | ||
Feature: | ||
As a developer | ||
In order to use mercury | ||
I should be able to use a generator to setup my application | ||
|
||
|
||
Scenario: A developer I want a basic install of mercury | ||
Given I have created a new rails application | ||
When I run `bundle exec rails generate mercury:install --trace` interactively | ||
And I type "N" | ||
And I type "N" | ||
Then the following files should exist: | ||
| app/assets/javascripts/mercury.js | | ||
And the file "config/routes.rb" should contain "mount Mercury::Engine => '/'" | ||
|
||
Scenario: A developer I want a full install of mercury | ||
Given I have created a new rails application | ||
When I successfully run `bundle exec rails generate mercury:install --full --trace` | ||
Then the following files should exist: | ||
| app/assets/javascripts/mercury.js | | ||
| app/assets/stylesheets/mercury_overrides.css | | ||
| app/views/layouts/mercury.html.erb | | ||
| lib/mercury/authentication.rb | | ||
And the file "config/routes.rb" should contain "mount Mercury::Engine => '/'" | ||
|
||
Scenario: A developer I want to install the image backend for Mercury | ||
Given I have created a new rails application | ||
When I successfully run `bundle exec rails generate mercury:install:images --trace` | ||
Then the following files should exist: | ||
| app/controllers/mercury/images_controller.rb | | ||
| app/models/mercury/image.rb | | ||
And the file "app/models/mercury/image.rb" should contain "class Mercury::Image < ActiveRecord::Base" | ||
And should have the migration "create_mercury_images.rb" | ||
And the file "config/routes.rb" should contain: | ||
""" | ||
namespace :mercury do | ||
resources :images | ||
end | ||
""" | ||
And the file "Gemfile" should contain "gem 'paperclip'" | ||
|
||
Scenario: A developer I want to install the image backend for Mercury with Mongoid | ||
Given I have created a new rails application | ||
When I successfully run `bundle exec rails generate mercury:install:images --orm mongoid --trace` | ||
Then the following files should exist: | ||
| app/controllers/mercury/images_controller.rb | | ||
| app/models/mercury/image.rb | | ||
And the file "app/models/mercury/image.rb" should contain: | ||
""" | ||
class Mercury::Image | ||
include Mongoid::Document | ||
include Mongoid::Paperclip | ||
""" | ||
And should not have the migration "create_mercury_images.rb" | ||
And the file "config/routes.rb" should contain: | ||
""" | ||
namespace :mercury do | ||
resources :images | ||
end | ||
""" | ||
And the file "Gemfile" should contain "gem 'paperclip'" | ||
|
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,27 @@ | ||
When /^I add Mercury as a gem dependency$/ do | ||
append_to_file('Gemfile', %{\ngem "mercury-rails", :path => "#{File.expand_path('../../../', __FILE__)}"\n}) | ||
end | ||
|
||
When "I have created a new rails application" do | ||
step %{I reset Bundler environment variable} | ||
step %{I successfully run `bundle exec rails new testapp --skip-bundle`} | ||
step %{I cd to "testapp"} | ||
step %{I add Mercury as a gem dependency} | ||
step %{I run `bundle install --local`} | ||
end | ||
|
||
Then /^the file "([^"]*)" should contain:$/ do |file, partial_content| | ||
check_file_content(file, partial_content, true) | ||
end | ||
|
||
Then /^should have the migration "([^"]*)"$/ do |migration| | ||
in_current_dir do | ||
Dir["db/migrate/*_#{migration}"].length.should == 1 | ||
end | ||
end | ||
|
||
Then /^should not have the migration "([^"]*)"$/ do |migration| | ||
in_current_dir do | ||
Dir["db/migrate/*_#{migration}"].length.should == 0 | ||
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE) | ||
ORIGINAL_BUNDLE_VARS = Hash[ENV.select{ |key,value| BUNDLE_ENV_VARS.include?(key) }] | ||
|
||
Before do | ||
if ! ENV['BUNDLE_GEMFILE'].include?(Dir.pwd) | ||
ENV['BUNDLE_GEMFILE'] = File.join(Dir.pwd, ENV['BUNDLE_GEMFILE']) | ||
end | ||
end | ||
|
||
After do | ||
ORIGINAL_BUNDLE_VARS.each_pair do |key, value| | ||
ENV[key] = value | ||
end | ||
end | ||
|
||
When /^I reset Bundler environment variable$/ do | ||
BUNDLE_ENV_VARS.each do |key| | ||
ENV[key] = nil | ||
end | ||
end | ||
|
||
Before do | ||
@aruba_timeout_seconds = 20 | ||
end | ||
|
||
Before('@slow') do | ||
@aruba_timeout_seconds = 180 | ||
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
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,42 @@ | ||
require 'rails/generators/active_record' | ||
module Mercury | ||
module Generators | ||
module Install | ||
class ImagesGenerator < Rails::Generators::Base | ||
include Rails::Generators::Migration | ||
source_root File.expand_path("../templates", __FILE__) | ||
|
||
class_option :orm, :default => 'active_record', :banner => 'mongoid', | ||
:desc => 'ORM for required models -- active_record, or mongoid' | ||
|
||
def copy_models | ||
if options[:orm] == 'mongoid' | ||
copy_file 'mongoid_paperclip_image.rb', 'app/models/mercury/image.rb' | ||
else | ||
copy_file 'ar_paperclip_image.rb', 'app/models/mercury/image.rb' | ||
migration_template 'ar_paperclip_image_migration.rb', 'db/migrate/create_mercury_images.rb' | ||
end | ||
end | ||
|
||
def copy_controller | ||
copy_file 'images_controller.rb', 'app/controllers/mercury/images_controller.rb' | ||
end | ||
|
||
def add_routes | ||
route %Q{ namespace :mercury do | ||
resources :images | ||
end} | ||
end | ||
|
||
def add_gemfile_dependencies | ||
prepend_to_file "Gemfile", %Q{gem 'paperclip'} | ||
end | ||
|
||
# Implement the required interface for Rails::Generators::Migration. | ||
def self.next_migration_number(dirname) #:nodoc: | ||
ActiveRecord::Generators::Base.next_migration_number(dirname) | ||
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,7 +1,5 @@ | ||
require 'paperclip' | ||
|
||
# module Mercury | ||
# end | ||
module Mercury | ||
end | ||
|
||
require 'mercury/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,3 @@ | ||
module Mercury | ||
VERSION = '0.4.0' | ||
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
This file was deleted.
Oops, something went wrong.