From 276e0fd885542a9fcb3e0f84b7e6f547f67bc582 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Fri, 10 Jan 2014 16:48:23 +0800 Subject: [PATCH] Added Categories, Search --- Gemfile | 6 +- Gemfile.lock | 36 +++++++++- app/assets/javascripts/search.js.coffee | 3 + app/assets/stylesheets/scaffolds.css.scss | 69 ------------------- app/assets/stylesheets/search.css.scss | 3 + .../api/v1/extensions_controller.rb | 1 + .../api/v1/templates_controller.rb | 1 + .../oauth/applications_controller.rb | 20 ++++++ app/controllers/search_controller.rb | 7 ++ app/helpers/search_helper.rb | 2 + app/models/ability.rb | 33 +++++++++ app/models/category.rb | 8 +++ app/models/concerns/category_filter.rb | 13 ++++ app/models/doorkeeper/application.rb | 30 ++++++++ app/models/extension.rb | 9 +++ app/models/role.rb | 16 +++++ app/models/template.rb | 7 ++ app/models/user.rb | 2 + app/views/search/index.html.erb | 2 + app/views/search/show.html.erb | 2 + config/initializers/doorkeeper.rb | 67 ++++++++++++++++++ config/initializers/rolify.rb | 8 +++ config/locales/doorkeeper.en.yml | 68 ++++++++++++++++++ config/routes.rb | 6 ++ db/seeds.rb | 3 +- lib/tasks/run_index.rake | 8 +++ test/controllers/search_controller_test.rb | 14 ++++ test/fixtures/categories.yml | 9 +++ test/fixtures/roles.yml | 11 +++ test/helpers/search_helper_test.rb | 4 ++ test/models/category_test.rb | 7 ++ test/models/role_test.rb | 7 ++ 32 files changed, 408 insertions(+), 74 deletions(-) create mode 100644 app/assets/javascripts/search.js.coffee delete mode 100644 app/assets/stylesheets/scaffolds.css.scss create mode 100644 app/assets/stylesheets/search.css.scss create mode 100644 app/controllers/oauth/applications_controller.rb create mode 100644 app/controllers/search_controller.rb create mode 100644 app/helpers/search_helper.rb create mode 100644 app/models/ability.rb create mode 100644 app/models/category.rb create mode 100644 app/models/concerns/category_filter.rb create mode 100644 app/models/doorkeeper/application.rb create mode 100644 app/models/role.rb create mode 100644 app/views/search/index.html.erb create mode 100644 app/views/search/show.html.erb create mode 100644 config/initializers/doorkeeper.rb create mode 100644 config/initializers/rolify.rb create mode 100644 config/locales/doorkeeper.en.yml create mode 100644 lib/tasks/run_index.rake create mode 100644 test/controllers/search_controller_test.rb create mode 100644 test/fixtures/categories.yml create mode 100644 test/fixtures/roles.yml create mode 100644 test/helpers/search_helper_test.rb create mode 100644 test/models/category_test.rb create mode 100644 test/models/role_test.rb diff --git a/Gemfile b/Gemfile index 8a4e60f..ce8fca9 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,13 @@ gem 'rails', '4.0.2' gem 'mongoid', github: 'mongoid/mongoid' gem 'bson_ext' +gem 'mongoid-elasticsearch' gem 'devise' +gem 'warden' +gem 'doorkeeper', github: 'shinzui/doorkeeper' +gem 'cancan' +gem 'rolify', :github => 'EppO/rolify' gem 'mongoid_slug', github: 'digitalplaywright/mongoid-slug' gem 'carrierwave' @@ -21,7 +26,6 @@ gem "font-awesome-rails", github: "bokmann/font-awesome-rails" gem 'rmagick' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.0' -gem 'apipie-rails' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' diff --git a/Gemfile.lock b/Gemfile.lock index f09acfc..af56aa6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,9 @@ +GIT + remote: git://github.com/EppO/rolify.git + revision: 45de8cf4bf51e60accddee3385829a2266709cb0 + specs: + rolify (3.3.0.rc5) + GIT remote: git://github.com/ahoward/mongoid-grid_fs.git revision: 059012a2c2a9e0a5d6e67137752c3e918689c88a @@ -40,6 +46,13 @@ GIT origin (~> 2.0) tzinfo (~> 0.3.37) +GIT + remote: git://github.com/shinzui/doorkeeper.git + revision: 8f67bd06945983cf9fd1b883a09cb51bc9ffe32e + specs: + doorkeeper (1.0.0.rc1) + railties (>= 3.1) + GEM remote: https://rubygems.org/ specs: @@ -67,14 +80,13 @@ GEM multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) - apipie-rails (0.0.24) - rails (>= 3.0.10) arel (4.0.1) atomic (1.1.14) bcrypt-ruby (3.1.2) bson (2.0.0) bson_ext (1.5.1) builder (3.1.4) + cancan (1.6.10) carrierwave (0.9.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) @@ -96,8 +108,18 @@ GEM railties (>= 3.2.6, < 5) thread_safe (~> 0.1) warden (~> 1.2.3) + elasticsearch (0.4.5) + elasticsearch-api (= 0.4.5) + elasticsearch-transport (= 0.4.5) + elasticsearch-api (0.4.5) + multi_json + elasticsearch-transport (0.4.5) + faraday + multi_json erubis (2.7.0) execjs (2.0.2) + faraday (0.8.9) + multipart-post (~> 1.2.0) hike (1.2.3) i18n (0.6.9) jbuilder (1.5.3) @@ -112,11 +134,15 @@ GEM treetop (~> 1.4.8) mime-types (1.25.1) minitest (4.7.5) + mongoid-elasticsearch (0.4.3) + elasticsearch (~> 0.4.1) + mongoid (~> 4.0.0.alpha1) moped (2.0.0.beta4) bson (~> 2.0) connection_pool (~> 1.2) optionable (~> 0.2.0) multi_json (1.8.2) + multipart-post (1.2.0) optionable (0.2.0) origin (2.0.0) orm_adapter (0.5.0) @@ -182,22 +208,26 @@ PLATFORMS DEPENDENCIES anjlab-bootstrap-rails! - apipie-rails bson_ext + cancan carrierwave carrierwave-mongoid coffee-rails (~> 4.0.0) devise + doorkeeper! font-awesome-rails! jbuilder (~> 1.2) jquery-rails mongoid! + mongoid-elasticsearch mongoid-grid_fs! mongoid_slug! puma rails (= 4.0.2) rmagick + rolify! sass-rails (~> 4.0.0) sdoc turbolinks uglifier (>= 1.3.0) + warden diff --git a/app/assets/javascripts/search.js.coffee b/app/assets/javascripts/search.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/search.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss deleted file mode 100644 index 6ec6a8f..0000000 --- a/app/assets/stylesheets/scaffolds.css.scss +++ /dev/null @@ -1,69 +0,0 @@ -body { - background-color: #fff; - color: #333; - font-family: verdana, arial, helvetica, sans-serif; - font-size: 13px; - line-height: 18px; -} - -p, ol, ul, td { - font-family: verdana, arial, helvetica, sans-serif; - font-size: 13px; - line-height: 18px; -} - -pre { - background-color: #eee; - padding: 10px; - font-size: 11px; -} - -a { - color: #000; - &:visited { - color: #666; - } - &:hover { - color: #fff; - background-color: #000; - } -} - -div { - &.field, &.actions { - margin-bottom: 10px; - } -} - -#notice { - color: green; -} - -.field_with_errors { - padding: 2px; - background-color: red; - display: table; -} - -#error_explanation { - width: 450px; - border: 2px solid red; - padding: 7px; - padding-bottom: 0; - margin-bottom: 20px; - background-color: #f0f0f0; - h2 { - text-align: left; - font-weight: bold; - padding: 5px 5px 5px 15px; - font-size: 12px; - margin: -7px; - margin-bottom: 0px; - background-color: #c00; - color: #fff; - } - ul li { - font-size: 12px; - list-style: square; - } -} diff --git a/app/assets/stylesheets/search.css.scss b/app/assets/stylesheets/search.css.scss new file mode 100644 index 0000000..22fd394 --- /dev/null +++ b/app/assets/stylesheets/search.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the search controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/api/v1/extensions_controller.rb b/app/controllers/api/v1/extensions_controller.rb index 736e434..0d226ef 100644 --- a/app/controllers/api/v1/extensions_controller.rb +++ b/app/controllers/api/v1/extensions_controller.rb @@ -1,6 +1,7 @@ module Api module V1 class ExtensionsController < ApplicationController + doorkeeper_for :all respond_to :json def index diff --git a/app/controllers/api/v1/templates_controller.rb b/app/controllers/api/v1/templates_controller.rb index 4c72edd..91d5977 100644 --- a/app/controllers/api/v1/templates_controller.rb +++ b/app/controllers/api/v1/templates_controller.rb @@ -1,6 +1,7 @@ module Api module V1 class TemplatesController < ApplicationController + doorkeeper_for :all, :scopes => [:public] respond_to :json def index diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb new file mode 100644 index 0000000..755d008 --- /dev/null +++ b/app/controllers/oauth/applications_controller.rb @@ -0,0 +1,20 @@ +class Oauth::ApplicationsController < Doorkeeper::ApplicationsController + before_filter :authenticate_user! + + def index + @applications = current_user.oauth_applications + end + + # only needed if each application must have some owner + def create + @application = Doorkeeper::Application.new(application_params) + @application.owner = current_user if Doorkeeper.configuration.confirm_application_owner? + if @application.save + flash[:notice] = I18n.t(:notice, :scope => [:doorkeeper, :flash, :applications, :create]) + respond_with [:oauth, @application] + else + render :new + end + end + +end \ No newline at end of file diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb new file mode 100644 index 0000000..b376eb9 --- /dev/null +++ b/app/controllers/search_controller.rb @@ -0,0 +1,7 @@ +class SearchController < ApplicationController + def index + end + + def show + end +end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb new file mode 100644 index 0000000..b3ce20a --- /dev/null +++ b/app/helpers/search_helper.rb @@ -0,0 +1,2 @@ +module SearchHelper +end diff --git a/app/models/ability.rb b/app/models/ability.rb new file mode 100644 index 0000000..4f7177b --- /dev/null +++ b/app/models/ability.rb @@ -0,0 +1,33 @@ +class Ability + include CanCan::Ability + + def initialize(user) + # Define abilities for the passed in user here. For example: + # + user ||= User.new # guest user (not logged in) + if user.has_role? :admin + can :manage, :all + else + can :read, Template + can :read, Extension + end + # + # The first argument to `can` is the action you are giving the user + # permission to do. + # If you pass :manage it will apply to every action. Other common actions + # here are :read, :create, :update and :destroy. + # + # The second argument is the resource the user can perform the action on. + # If you pass :all it will apply to every resource. Otherwise pass a Ruby + # class of the resource. + # + # The third argument is an optional hash of conditions to further filter the + # objects. + # For example, here the user can only update published articles. + # + # can :update, Article, :published => true + # + # See the wiki for details: + # https://github.com/ryanb/cancan/wiki/Defining-Abilities + end +end diff --git a/app/models/category.rb b/app/models/category.rb new file mode 100644 index 0000000..c0f5e5b --- /dev/null +++ b/app/models/category.rb @@ -0,0 +1,8 @@ +class Category + include Mongoid::Document + field :title, type: String + field :type, type: String + + has_many :templates + has_many :extensions +end diff --git a/app/models/concerns/category_filter.rb b/app/models/concerns/category_filter.rb new file mode 100644 index 0000000..85eb2bf --- /dev/null +++ b/app/models/concerns/category_filter.rb @@ -0,0 +1,13 @@ +module CategoryFilter + extend ActiveSupport::Concern + + included do + scope :all_category, where(type: name.to_s) + end + + # module ClassMethods + # def filter_by_category(category_id) + # product_"#{name}" = name.where(category_id: category_id) + # end + # end +end \ No newline at end of file diff --git a/app/models/doorkeeper/application.rb b/app/models/doorkeeper/application.rb new file mode 100644 index 0000000..25aae03 --- /dev/null +++ b/app/models/doorkeeper/application.rb @@ -0,0 +1,30 @@ +module Doorkeeper + class Application + include Mongoid::Document + include Mongoid::Timestamps + + self.store_in collection: :oauth_applications + + field :name, :type => String + field :uid, :type => String + field :secret, :type => String + field :redirect_uri, :type => String + field :owner_id, :type => String + field :owner_type, :type => String + + + index({ + uid: 1, + owner_id: 1, + owner_type: 1 + }, + { unique: true }) + + has_many :authorized_tokens, :class_name => "Doorkeeper::AccessToken" + + def self.authorized_for(resource_owner) + ids = AccessToken.where(:resource_owner_id => resource_owner.id, :revoked_at => nil).map(&:application_id) + find(ids) + end + end +end \ No newline at end of file diff --git a/app/models/extension.rb b/app/models/extension.rb index 0fd5dd6..7e1d3ca 100644 --- a/app/models/extension.rb +++ b/app/models/extension.rb @@ -2,14 +2,23 @@ class Extension include Mongoid::Document include Mongoid::Timestamps include Mongoid::Slug + include Mongoid::Elasticsearch + + include CategoryFilter field :title, type: String field :author, type: String field :preview, type: String field :extension, type: String field :description, type: String + field :category_id, type: String + slug :title, history: true + belongs_to :category + mount_uploader :preview, ImageUploader mount_uploader :extension, ProductUploader + + elasticsearch! end diff --git a/app/models/role.rb b/app/models/role.rb new file mode 100644 index 0000000..8e5d8de --- /dev/null +++ b/app/models/role.rb @@ -0,0 +1,16 @@ +class Role + include Mongoid::Document + has_and_belongs_to_many :users + belongs_to :resource, :polymorphic => true + + field :name, :type => String + + index({ + :name => 1, + :resource_type => 1, + :resource_id => 1 + }, + { :unique => true}) + + scopify +end diff --git a/app/models/template.rb b/app/models/template.rb index d1c993e..b80dd52 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -1,14 +1,21 @@ class Template + include Mongoid::Document include Mongoid::Timestamps include Mongoid::Slug + include Mongoid::Elasticsearch field :title, type: String field :author, type: String field :preview, type: String field :template, type: String + field :category_id, type: String + slug :title, history: true + belongs_to :category mount_uploader :preview, ImageUploader mount_uploader :template, ProductUploader + + elasticsearch! end diff --git a/app/models/user.rb b/app/models/user.rb index 5c0a987..ec9b769 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,6 @@ class User include Mongoid::Document + rolify # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, @@ -33,4 +34,5 @@ class User # field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts # field :unlock_token, :type => String # Only if unlock strategy is :email or :both # field :locked_at, :type => Time + has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner end diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb new file mode 100644 index 0000000..5a2cd58 --- /dev/null +++ b/app/views/search/index.html.erb @@ -0,0 +1,2 @@ +

Search#index

+

Find me in app/views/search/index.html.erb

diff --git a/app/views/search/show.html.erb b/app/views/search/show.html.erb new file mode 100644 index 0000000..ee5257b --- /dev/null +++ b/app/views/search/show.html.erb @@ -0,0 +1,2 @@ +

Search#show

+

Find me in app/views/search/show.html.erb

diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb new file mode 100644 index 0000000..7bd9070 --- /dev/null +++ b/config/initializers/doorkeeper.rb @@ -0,0 +1,67 @@ +Doorkeeper.configure do + # Change the ORM that doorkeeper will use. + # Currently supported options are :active_record, :mongoid2, :mongoid3, :mongo_mapper + orm :mongoid4 + + # This block will be called to check whether the resource owner is authenticated or not. + resource_owner_from_credentials do |routes| + request.params[:user] = {:email => request.params[:username], :password => request.params[:password]} + request.env["devise.allow_params_authentication"] = true + request.env["warden"].authenticate!(:scope => :user) + end + + # If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below. + admin_authenticator do + # # Put your admin authentication logic here. + # # Example implementation: + redirect_to root_url unless current_user.try(:has_role?, :admin) + # Admin.find_by_id(session[:admin_id]) || redirect_to(new_admin_session_url) + end + + # Authorization Code expiration time (default 10 minutes). + # authorization_code_expires_in 10.minutes + + # Access token expiration time (default 2 hours). + # If you want to disable expiration, set this to nil. + # access_token_expires_in 2.hours + + # Issue access tokens with refresh token (disabled by default) + # use_refresh_token + + # Provide support for an owner to be assigned to each registered application (disabled by default) + # Optional parameter :confirmation => true (default false) if you want to enforce ownership of + # a registered application + # Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support + enable_application_owner :confirmation => false + + # Define access token scopes for your provider + # For more information go to https://github.com/applicake/doorkeeper/wiki/Using-Scopes + # default_scopes :public + # optional_scopes :write, :update + + # Change the way client credentials are retrieved from the request object. + # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then + # falls back to the `:client_id` and `:client_secret` params from the `params` object. + # Check out the wiki for more information on customization + # client_credentials :from_basic, :from_params + + # Change the way access token is authenticated from the request object. + # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then + # falls back to the `:access_token` or `:bearer_token` params from the `params` object. + # Check out the wiki for more information on customization + # access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param + + # Change the test redirect uri for client apps + # When clients register with the following redirect uri, they won't be redirected to any server and the authorization code will be displayed within the provider + # The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL + # (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi) + # + # test_redirect_uri 'urn:ietf:wg:oauth:2.0:oob' + + # Under some circumstances you might want to have applications auto-approved, + # so that the user skips the authorization step. + # For example if dealing with trusted a application. + # skip_authorization do |resource_owner, client| + # client.superapp? or resource_owner.admin? + # end +end diff --git a/config/initializers/rolify.rb b/config/initializers/rolify.rb new file mode 100644 index 0000000..112cbe8 --- /dev/null +++ b/config/initializers/rolify.rb @@ -0,0 +1,8 @@ +Rolify.configure do |config| + # By default ORM adapter is ActiveRecord. uncomment to use mongoid + config.use_mongoid + + # Dynamic shortcuts for User class (user.is_admin? like methods). Default is: false + # Enable this feature _after_ running rake db:migrate as it relies on the roles table + # config.use_dynamic_shortcuts +end \ No newline at end of file diff --git a/config/locales/doorkeeper.en.yml b/config/locales/doorkeeper.en.yml new file mode 100644 index 0000000..8a51ce2 --- /dev/null +++ b/config/locales/doorkeeper.en.yml @@ -0,0 +1,68 @@ +en: + activerecord: + errors: + models: + application: + attributes: + redirect_uri: + fragment_present: 'cannot contain a fragment.' + has_query_parameter: 'cannot contain a query parameter.' + invalid_uri: 'must be a valid URI.' + relative_uri: 'must be an absolute URI.' + mongoid: + errors: + models: + application: + attributes: + redirect_uri: + fragment_present: 'cannot contain a fragment.' + has_query_parameter: 'cannot contain a query parameter.' + invalid_uri: 'must be a valid URI.' + relative_uri: 'must be an absolute URI.' + mongo_mapper: + errors: + models: + application: + attributes: + redirect_uri: + fragment_present: 'cannot contain a fragment.' + has_query_parameter: 'cannot contain a query parameter.' + invalid_uri: 'must be a valid URI.' + relative_uri: 'must be an absolute URI.' + doorkeeper: + errors: + messages: + # Common error messages + invalid_request: 'The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed.' + invalid_redirect_uri: 'The redirect uri included is not valid.' + unauthorized_client: 'The client is not authorized to perform this request using this method.' + access_denied: 'The resource owner or authorization server denied the request.' + invalid_scope: 'The requested scope is invalid, unknown, or malformed.' + server_error: 'The authorization server encountered an unexpected condition which prevented it from fulfilling the request.' + temporarily_unavailable: 'The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server.' + + #configuration error messages + credential_flow_not_configured: 'Resource Owner Password Credentials flow failed due to Doorkeeper.configure.resource_owner_from_credentials being unconfigured.' + resource_owner_authenticator_not_configured: 'Resource Owner find failed due to Doorkeeper.configure.resource_owner_authenticator being unconfiged.' + + # Access grant errors + unsupported_response_type: 'The authorization server does not support this response type.' + + # Access token errors + invalid_client: 'Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.' + invalid_grant: 'The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.' + unsupported_grant_type: 'The authorization grant type is not supported by the authorization server.' + + # Password Access token errors + invalid_resource_owner: 'The provided resource owner credentials are not valid, or resource owner cannot be found' + flash: + applications: + create: + notice: 'Application created.' + destroy: + notice: 'Application deleted.' + update: + notice: 'Application updated.' + authorized_applications: + destroy: + notice: 'Application revoked.' diff --git a/config/routes.rb b/config/routes.rb index 51ccd64..8945509 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,12 @@ require 'api_constraints' Mtstore::Application.routes.draw do + get "search/index" + get "search/show" + use_doorkeeper do + controllers :applications => 'oauth/applications' + end + devise_for :users namespace :api, defaults: {format: 'json'} do scope module: :v1, constraints: ApiConstraints.new(version: 1, default: :true) do diff --git a/db/seeds.rb b/db/seeds.rb index ec80413..9a0d616 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,4 +5,5 @@ # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) -user = User.create :email => "orbit@rulingcom.com", :password => "bjo4xjp6", :password_confirmation => "bjo4xjp6" +user = User.create(:email => "orbit@rulingcom.com", :password => "bjo4xjp6", :password_confirmation => "bjo4xjp6") +category = Category.create([{ title: "Science", type: "Template" },{ title: "Responsive", type: "Template" },{ title: "Organizer", type: "Extension" }, { title: "Productivity", type: "Extension" }, { title: "Location", type: "Extension" }]) diff --git a/lib/tasks/run_index.rake b/lib/tasks/run_index.rake new file mode 100644 index 0000000..22c1836 --- /dev/null +++ b/lib/tasks/run_index.rake @@ -0,0 +1,8 @@ +namespace :run_index do + task :once => :environment do + Extension.es.index_all + puts "Index Created for Extension" + Template.es.index_all + puts "Index Created for Templates" + end +end \ No newline at end of file diff --git a/test/controllers/search_controller_test.rb b/test/controllers/search_controller_test.rb new file mode 100644 index 0000000..bcbc11f --- /dev/null +++ b/test/controllers/search_controller_test.rb @@ -0,0 +1,14 @@ +require 'test_helper' + +class SearchControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + + test "should get show" do + get :show + assert_response :success + end + +end diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml new file mode 100644 index 0000000..9c3f31a --- /dev/null +++ b/test/fixtures/categories.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + type: + +two: + title: MyString + type: diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/roles.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/helpers/search_helper_test.rb b/test/helpers/search_helper_test.rb new file mode 100644 index 0000000..3034163 --- /dev/null +++ b/test/helpers/search_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class SearchHelperTest < ActionView::TestCase +end diff --git a/test/models/category_test.rb b/test/models/category_test.rb new file mode 100644 index 0000000..4733541 --- /dev/null +++ b/test/models/category_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CategoryTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/role_test.rb b/test/models/role_test.rb new file mode 100644 index 0000000..11c53a8 --- /dev/null +++ b/test/models/role_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RoleTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end