Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add forem:views generator, which copies over the forem views into you…

…r application
  • Loading branch information...
commit 1b3b89a9b3adc5054e6ca7389e48aa5b0ed1fce5 1 parent b11f562
@radar radar authored
View
24 lib/generators/forem/views_generator.rb
@@ -0,0 +1,24 @@
+# Thanks to plataformatec/devise
+# The code used to inspire this generator!
+require 'rails/generators'
+module Forem
+ module Generators
+ class ViewsGenerator < Rails::Generators::Base #:nodoc:
+ source_root File.expand_path("../../../../app/views/forem", __FILE__)
+ desc "Used to copy forem's views to your application's views."
+
+ def copy_views
+ view_directory :admin
+ view_directory :forums
+ view_directory :posts
+ view_directory :topics
+ end
+
+ protected
+
+ def view_directory(name)
+ directory name.to_s, "app/views/forem/#{name}"
+ end
+ end
+ end
+end
View
19 spec/generators/views_generator.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+require 'generators/forem/views_generator'
+
+describe Forem::Generators::ViewsGenerator do
+ let(:views) { Rails.root + "app/views" }
+
+ # Ensure directory is missing before generator is running
+ before { FileUtils.rm_r(views + "forem") }
+ # And clean up once we are done
+ after { FileUtils.rm_r(views + "forem") }
+
+ it "copies over files" do
+ capture(:stdout) { described_class.start([], :destination_root => Rails.root) }
+ dirs = ["forem", "forem/admin", "forem/forums", "forem/posts", "forem/topics"]
+ dirs.each do |dir|
+ assert File.directory?(views + dir), "did not generate #{dir}"
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.