├── .gitignore ├── .rspec ├── .rvmrc ├── Gemfile ├── Gemfile.lock ├── Guardfile ├── History.md ├── MIT-LICENSE ├── README.rdoc ├── Rakefile ├── active_admin-awesome_nested_set.gemspec ├── config └── locales │ ├── active_admin-awesome_nested_set.de.yml │ ├── active_admin-awesome_nested_set.en.yml │ └── active_admin-awesome_nested_set.ru.yml ├── lib ├── active_admin-awesome_nested_set.rb ├── active_admin │ ├── awesome_nested_set │ │ ├── engine.rb │ │ ├── helper.rb │ │ └── version.rb │ └── views │ │ └── index_as_nested_set.rb └── tasks │ └── active_admin-awesome_nested_set_tasks.rake └── spec ├── dummy ├── README.rdoc ├── Rakefile ├── app │ ├── admin │ │ ├── admin_users.rb │ │ ├── categories.rb │ │ └── dashboard.rb │ ├── assets │ │ ├── javascripts │ │ │ ├── active_admin.js │ │ │ └── application.js │ │ └── stylesheets │ │ │ ├── active_admin.css.scss │ │ │ └── application.css │ ├── controllers │ │ └── application_controller.rb │ ├── helpers │ │ └── application_helper.rb │ ├── mailers │ │ └── .gitkeep │ ├── models │ │ ├── .gitkeep │ │ ├── admin_user.rb │ │ └── category.rb │ └── views │ │ └── layouts │ │ └── application.html.erb ├── config.ru ├── config │ ├── application.rb │ ├── boot.rb │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── initializers │ │ ├── active_admin.rb │ │ ├── backtrace_silencers.rb │ │ ├── devise.rb │ │ ├── inflections.rb │ │ ├── mime_types.rb │ │ ├── secret_token.rb │ │ ├── session_store.rb │ │ └── wrap_parameters.rb │ ├── locales │ │ ├── active_admin.en.yml │ │ ├── devise.en.yml │ │ └── en.yml │ └── routes.rb ├── db │ ├── development.sqlite3 │ ├── migrate │ │ ├── 20130228120819_devise_create_admin_users.rb │ │ ├── 20130228120821_create_admin_notes.rb │ │ ├── 20130228120822_move_admin_notes_to_comments.rb │ │ └── 20130228121407_create_categories.rb │ ├── schema.rb │ └── test.sqlite3 ├── lib │ └── assets │ │ └── .gitkeep ├── log │ ├── .gitkeep │ └── test.log ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ └── favicon.ico ├── script │ └── rails ├── spec └── test │ └── factories │ └── categories.rb ├── factories ├── admin_user_factories.rb └── category_factories.rb ├── features ├── categories_admin_feature_spec.rb └── sortable_tree_feature_spec.rb ├── models ├── category_spec.rb └── generic_spec.rb ├── spec_helper.rb └── support ├── active_admin └── sign_in_helper.rb └── factory_girl.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .bundle/ 2 | log/*.log 3 | pkg/ 4 | spec/dummy/db/*.sqlite3 5 | spec/dummy/log/*.log 6 | spec/dummy/tmp/ 7 | spec/dummy/.sass-cache 8 | *.gem 9 | .yardoc/ 10 | tmp/ 11 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color --format documentation 2 | 3 | -------------------------------------------------------------------------------- /.rvmrc: -------------------------------------------------------------------------------- 1 | rvm --create use default@${PWD##/*/} 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Declare your gem's dependencies in active_admin-acts_as_list.gemspec. 4 | # Bundler will treat runtime dependencies like base dependencies, and 5 | # development dependencies will be added by default to the :development group. 6 | gemspec 7 | 8 | # jquery-rails is used by the dummy application 9 | gem "jquery-rails" 10 | 11 | # Declare any dependencies that are still in development here instead of in 12 | # your gemspec. These might include edge Rails or gems from your path or 13 | # Git. Remember to move these dependencies to your gemspec before releasing 14 | # your gem to rubygems.org. 15 | 16 | # To use debugger 17 | # gem 'debugger' 18 | 19 | # Patched guard rails 20 | gem 'guard-rails', :git => 'git://github.com/robotex82/guard-rails.git', :branch => 'better-engine-support' 21 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: git://github.com/robotex82/guard-rails.git 3 | revision: 2b0d43bd01c32363b4919bca372973224b3cbab1 4 | branch: better-engine-support 5 | specs: 6 | guard-rails (0.1.0) 7 | guard (>= 0.2.2) 8 | 9 | PATH 10 | remote: . 11 | specs: 12 | active_admin-awesome_nested_set (0.0.4) 13 | rails (~> 3.2.5) 14 | 15 | GEM 16 | remote: https://rubygems.org/ 17 | specs: 18 | actionmailer (3.2.12) 19 | actionpack (= 3.2.12) 20 | mail (~> 2.4.4) 21 | actionpack (3.2.12) 22 | activemodel (= 3.2.12) 23 | activesupport (= 3.2.12) 24 | builder (~> 3.0.0) 25 | erubis (~> 2.7.0) 26 | journey (~> 1.0.4) 27 | rack (~> 1.4.5) 28 | rack-cache (~> 1.2) 29 | rack-test (~> 0.6.1) 30 | sprockets (~> 2.2.1) 31 | activeadmin (0.5.1) 32 | arbre (>= 1.0.1) 33 | bourbon (>= 1.0.0) 34 | devise (>= 1.1.2) 35 | fastercsv 36 | formtastic (>= 2.0.0) 37 | inherited_resources (>= 1.3.1) 38 | jquery-rails (>= 1.0.0) 39 | kaminari (>= 0.13.0) 40 | meta_search (>= 0.9.2) 41 | rails (>= 3.0.0) 42 | sass (>= 3.1.0) 43 | activemodel (3.2.12) 44 | activesupport (= 3.2.12) 45 | builder (~> 3.0.0) 46 | activerecord (3.2.12) 47 | activemodel (= 3.2.12) 48 | activesupport (= 3.2.12) 49 | arel (~> 3.0.2) 50 | tzinfo (~> 0.3.29) 51 | activeresource (3.2.12) 52 | activemodel (= 3.2.12) 53 | activesupport (= 3.2.12) 54 | activesupport (3.2.12) 55 | i18n (~> 0.6) 56 | multi_json (~> 1.0) 57 | arbre (1.0.1) 58 | activesupport (>= 3.0.0) 59 | arel (3.0.2) 60 | awesome_nested_set (2.1.6) 61 | activerecord (>= 3.0.0) 62 | bcrypt-ruby (3.0.1) 63 | bourbon (3.1.1) 64 | sass (>= 3.2.0) 65 | thor 66 | bourne (1.1.2) 67 | mocha (= 0.10.5) 68 | builder (3.0.4) 69 | capybara (2.0.2) 70 | mime-types (>= 1.16) 71 | nokogiri (>= 1.3.3) 72 | rack (>= 1.0.0) 73 | rack-test (>= 0.5.4) 74 | selenium-webdriver (~> 2.0) 75 | xpath (~> 1.0.0) 76 | childprocess (0.3.8) 77 | ffi (~> 1.0, >= 1.0.11) 78 | coderay (1.0.9) 79 | coffee-rails (3.2.2) 80 | coffee-script (>= 2.2.0) 81 | railties (~> 3.2.0) 82 | coffee-script (2.2.0) 83 | coffee-script-source 84 | execjs 85 | coffee-script-source (1.3.3) 86 | daemons (1.1.9) 87 | devise (2.2.3) 88 | bcrypt-ruby (~> 3.0) 89 | orm_adapter (~> 0.1) 90 | railties (~> 3.1) 91 | warden (~> 1.2.1) 92 | diff-lcs (1.2.1) 93 | erubis (2.7.0) 94 | eventmachine (1.0.1) 95 | execjs (1.4.0) 96 | multi_json (~> 1.0) 97 | factory_girl (2.6.4) 98 | activesupport (>= 2.3.9) 99 | factory_girl_rails (1.7.0) 100 | factory_girl (~> 2.6.0) 101 | railties (>= 3.0.0) 102 | fastercsv (1.5.5) 103 | ffi (1.4.0) 104 | formtastic (2.2.1) 105 | actionpack (>= 3.0) 106 | guard (1.6.2) 107 | listen (>= 0.6.0) 108 | lumberjack (>= 1.0.2) 109 | pry (>= 0.9.10) 110 | terminal-table (>= 1.4.3) 111 | thor (>= 0.14.6) 112 | guard-bundler (1.0.0) 113 | bundler (~> 1.0) 114 | guard (~> 1.1) 115 | guard-rspec (2.4.1) 116 | guard (>= 1.1) 117 | rspec (~> 2.11) 118 | has_scope (0.5.1) 119 | hike (1.2.1) 120 | i18n (0.6.4) 121 | inherited_resources (1.3.1) 122 | has_scope (~> 0.5.0) 123 | responders (~> 0.6) 124 | journey (1.0.4) 125 | jquery-rails (2.2.1) 126 | railties (>= 3.0, < 5.0) 127 | thor (>= 0.14, < 2.0) 128 | json (1.7.7) 129 | kaminari (0.14.1) 130 | actionpack (>= 3.0.0) 131 | activesupport (>= 3.0.0) 132 | listen (0.7.3) 133 | lumberjack (1.0.2) 134 | mail (2.4.4) 135 | i18n (>= 0.4.0) 136 | mime-types (~> 1.16) 137 | treetop (~> 1.4.8) 138 | meta_search (1.1.3) 139 | actionpack (~> 3.1) 140 | activerecord (~> 3.1) 141 | activesupport (~> 3.1) 142 | polyamorous (~> 0.5.0) 143 | metaclass (0.0.1) 144 | method_source (0.8.1) 145 | mime-types (1.21) 146 | mocha (0.10.5) 147 | metaclass (~> 0.0.1) 148 | multi_json (1.6.1) 149 | nokogiri (1.5.6) 150 | orm_adapter (0.4.0) 151 | polyamorous (0.5.0) 152 | activerecord (~> 3.0) 153 | polyglot (0.3.3) 154 | pry (0.9.12) 155 | coderay (~> 1.0.5) 156 | method_source (~> 0.8) 157 | slop (~> 3.4) 158 | rack (1.4.5) 159 | rack-cache (1.2) 160 | rack (>= 0.4) 161 | rack-ssl (1.3.3) 162 | rack 163 | rack-test (0.6.2) 164 | rack (>= 1.0) 165 | rails (3.2.12) 166 | actionmailer (= 3.2.12) 167 | actionpack (= 3.2.12) 168 | activerecord (= 3.2.12) 169 | activeresource (= 3.2.12) 170 | activesupport (= 3.2.12) 171 | bundler (~> 1.0) 172 | railties (= 3.2.12) 173 | railties (3.2.12) 174 | actionpack (= 3.2.12) 175 | activesupport (= 3.2.12) 176 | rack-ssl (~> 1.3.2) 177 | rake (>= 0.8.7) 178 | rdoc (~> 3.4) 179 | thor (>= 0.14.6, < 2.0) 180 | rake (10.0.3) 181 | rb-inotify (0.9.0) 182 | ffi (>= 0.5.0) 183 | rdoc (3.12.2) 184 | json (~> 1.4) 185 | responders (0.9.3) 186 | railties (~> 3.1) 187 | rspec (2.13.0) 188 | rspec-core (~> 2.13.0) 189 | rspec-expectations (~> 2.13.0) 190 | rspec-mocks (~> 2.13.0) 191 | rspec-core (2.13.0) 192 | rspec-expectations (2.13.0) 193 | diff-lcs (>= 1.1.3, < 2.0) 194 | rspec-mocks (2.13.0) 195 | rspec-rails (2.13.0) 196 | actionpack (>= 3.0) 197 | activesupport (>= 3.0) 198 | railties (>= 3.0) 199 | rspec-core (~> 2.13.0) 200 | rspec-expectations (~> 2.13.0) 201 | rspec-mocks (~> 2.13.0) 202 | rubyzip (0.9.9) 203 | sass (3.2.6) 204 | sass-rails (3.2.5) 205 | railties (~> 3.2.0) 206 | sass (>= 3.1.10) 207 | tilt (~> 1.3) 208 | selenium-webdriver (2.30.0) 209 | childprocess (>= 0.2.5) 210 | multi_json (~> 1.0) 211 | rubyzip 212 | websocket (~> 1.0.4) 213 | shoulda-matchers (1.4.2) 214 | activesupport (>= 3.0.0) 215 | bourne (~> 1.1.2) 216 | slop (3.4.3) 217 | sprockets (2.2.2) 218 | hike (~> 1.2) 219 | multi_json (~> 1.0) 220 | rack (~> 1.0) 221 | tilt (~> 1.1, != 1.3.0) 222 | sqlite3 (1.3.7) 223 | terminal-table (1.4.5) 224 | thin (1.5.0) 225 | daemons (>= 1.0.9) 226 | eventmachine (>= 0.12.6) 227 | rack (>= 1.0.0) 228 | thor (0.17.0) 229 | tilt (1.3.4) 230 | treetop (1.4.12) 231 | polyglot 232 | polyglot (>= 0.3.1) 233 | tzinfo (0.3.35) 234 | warden (1.2.1) 235 | rack (>= 1.0) 236 | websocket (1.0.7) 237 | xpath (1.0.0) 238 | nokogiri (~> 1.3) 239 | yard (0.8.5.2) 240 | 241 | PLATFORMS 242 | ruby 243 | 244 | DEPENDENCIES 245 | active_admin-awesome_nested_set! 246 | activeadmin 247 | awesome_nested_set 248 | capybara 249 | coffee-rails 250 | factory_girl_rails (~> 1.0) 251 | guard-bundler 252 | guard-rails! 253 | guard-rspec 254 | jquery-rails 255 | rb-inotify (~> 0.9) 256 | rspec-rails 257 | sass-rails 258 | shoulda-matchers 259 | sqlite3 260 | thin 261 | yard 262 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | # A sample Guardfile 2 | # More info at https://github.com/guard/guard#readme 3 | 4 | guard 'rails', :rails_root => 'spec/dummy' do 5 | watch('Gemfile.lock') 6 | watch(%r{^(config|lib)/.*(^\.rake)}) 7 | end 8 | 9 | guard 'rspec' do 10 | watch(%r{^spec/.+_spec\.rb$}) 11 | watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } 12 | watch('spec/spec_helper.rb') { "spec" } 13 | 14 | # Rails example 15 | watch(%r{^spec/dummy/app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } 16 | watch(%r{^spec/dummy/app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } 17 | watch(%r{^spec/dummy/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"] } 18 | watch(%r{^spec/support/(.+)\.rb$}) { "spec" } 19 | watch('spec/dummy/config/routes.rb') { "spec/routing" } 20 | watch('spec/dummy/app/controllers/application_controller.rb') { "spec/controllers" } 21 | 22 | # Capybara request specs 23 | watch(%r{^spec/dummy/app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } 24 | 25 | # Turnip features and steps 26 | watch(%r{^spec/acceptance/(.+)\.feature$}) 27 | watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } 28 | 29 | # Engine 30 | watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } 31 | watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } 32 | 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"] } 33 | watch('config/routes.rb') { "spec/routing" } 34 | watch('app/controllers/application_controller.rb') { "spec/controllers" } 35 | watch(%r{^app/models/(.+)\.rb$}) { |m| "spec/models/generic_spec.rb" } 36 | 37 | # Migrations 38 | watch(%r{^spec/migrations/.+_spec\.rb$}) 39 | watch(%r{^spec/dummy/db/migrate/[0-9]{14}_(.+)\.rb$}) { |m| "spec/migrations/#{m[1]}_spec.rb" } 40 | end 41 | 42 | guard 'bundler' do 43 | watch('Gemfile') 44 | watch('*.gemspec') 45 | end 46 | 47 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | n.n.n / 2015-04-01 3 | ================== 4 | 5 | * Merge pull request #7 from kagux/master 6 | * allow rails 4.2 7 | * update gemspec to allow rails 4.1 8 | * Merge pull request #3 from sandfox-im/master 9 | * Merge pull request #4 from rianrainey/patch-1 10 | * Merge pull request #6 from rianrainey/master 11 | * Add English translations. 12 | * Update README 13 | * Bumped version to 0.0.6 14 | * Merge branch 'master' of https://github.com/aderyabin/active_admin-awesome_nested_set into aderyabin-master 15 | * Allow both old and new rails 16 | * Allow both old and new rails 17 | * Update active_admin-awesome_nested_set.gemspec 18 | * rails4 compability 19 | * Enhancement: Added changelog 20 | * Bumped version to 0.0.5 21 | * Fixed: Helper not being found on show views. 22 | * Added indented column helper (thanks to Winton DeShong for this one) Added basic specs 23 | * Added index as tree. 24 | * Initial commit. 25 | 26 | 0.0.5 / 2013-04-15 27 | ================== 28 | 29 | * Fixed: Helper not being found on show views. 30 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013 Roberto Vasquez Angel 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | = ActiveAdminAwesomeNestedSet 2 | 3 | 4 | = Purpose 5 | 6 | Add sortable columns for active admin. Show index page as a tree. 7 | 8 | = Contributors 9 | 10 | * BrandyMint [https://github.com/BrandyMint] 11 | 12 | = Features 13 | 14 | * Add member actions with one method call 15 | * Add sorting columns in your index views with one method call. 16 | * Integrates with awesome_nested_set 17 | 18 | = Prerequisites 19 | 20 | You need active_admin and awesome_nested_set. 21 | 22 | = Installation 23 | 24 | Add it to your gemfile: 25 | 26 | gem 'active_admin-awesome_nested_set' 27 | 28 | Install your bundle: 29 | 30 | > bundle install 31 | 32 | = Usage 33 | 34 | Assuming you have a Category model: 35 | 36 | class Category < ActiveRecord::Base 37 | # awesome nested set 38 | acts_as_nested_set 39 | default_scope :order => 'lft ASC' 40 | 41 | #... 42 | end 43 | 44 | 45 | You can add sortable columns, member actions and sorting like this: 46 | 47 | #app/admin/category.rb 48 | ActiveAdmin.register Category do 49 | # Sort categories by left asc 50 | config.sort_order = 'lft_asc' 51 | 52 | # Add member actions for positioning. 53 | sortable_tree_member_actions 54 | 55 | index do 56 | # This adds columns for moving up, down, top and bottom. 57 | sortable_tree_columns 58 | 59 | #... 60 | column :firstname 61 | column :lastname 62 | default_actions 63 | end 64 | end 65 | 66 | = Todo 67 | 68 | * Tests, tests, tests. 69 | * Better docs. 70 | 71 | = License 72 | 73 | This project rocks and uses MIT-LICENSE. 74 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | begin 3 | require 'bundler/setup' 4 | rescue LoadError 5 | puts 'You must `gem install bundler` and `bundle install` to run rake tasks' 6 | end 7 | begin 8 | require 'rdoc/task' 9 | rescue LoadError 10 | require 'rdoc/rdoc' 11 | require 'rake/rdoctask' 12 | RDoc::Task = Rake::RDocTask 13 | end 14 | 15 | RDoc::Task.new(:rdoc) do |rdoc| 16 | rdoc.rdoc_dir = 'rdoc' 17 | rdoc.title = 'ActiveAdminActsAsList' 18 | rdoc.options << '--line-numbers' 19 | rdoc.rdoc_files.include('README.rdoc') 20 | rdoc.rdoc_files.include('lib/**/*.rb') 21 | end 22 | 23 | Bundler::GemHelper.install_tasks 24 | 25 | -------------------------------------------------------------------------------- /active_admin-awesome_nested_set.gemspec: -------------------------------------------------------------------------------- 1 | $:.push File.expand_path("../lib", __FILE__) 2 | 3 | # Maintain your gem's version: 4 | require "active_admin/awesome_nested_set/version" 5 | 6 | # Describe your gem and declare its dependencies: 7 | Gem::Specification.new do |s| 8 | s.name = "active_admin-awesome_nested_set" 9 | s.version = ActiveAdmin::AwesomeNestedSet::VERSION 10 | s.authors = ["Roberto Vasquez Angel"] 11 | s.email = ["roberto@vasquez-angel.de"] 12 | s.homepage = "https://github.com/robotex82/active_admin-awesome_nested_set" 13 | s.summary = "Provides sortable_columns helper in active admin resource definitions." 14 | s.description = "Provides sortable_columns helper in active admin resource definitions." 15 | 16 | s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"] 17 | 18 | s.add_dependency "rails", ">= 3.2.5", "< 5.0" 19 | 20 | # Development server 21 | s.add_development_dependency "thin" 22 | 23 | # Development database 24 | s.add_development_dependency "sqlite3" 25 | 26 | # Documentation 27 | s.add_development_dependency "yard" 28 | 29 | # Dummy app 30 | s.add_development_dependency 'activeadmin' 31 | s.add_development_dependency 'awesome_nested_set' 32 | s.add_development_dependency 'coffee-rails' 33 | s.add_development_dependency 'sass-rails' 34 | 35 | # Tests 36 | s.add_development_dependency 'capybara' 37 | s.add_development_dependency 'rspec-rails' 38 | s.add_development_dependency 'shoulda-matchers' 39 | s.add_development_dependency 'factory_girl_rails', '~> 1.0' 40 | 41 | # Test automation 42 | s.add_development_dependency 'guard-rspec' 43 | s.add_development_dependency 'guard-bundler' 44 | s.add_development_dependency 'rb-inotify', '~> 0.9' 45 | end 46 | 47 | -------------------------------------------------------------------------------- /config/locales/active_admin-awesome_nested_set.de.yml: -------------------------------------------------------------------------------- 1 | de: 2 | awesome_nested_set: 3 | moved_to_top: "%{resource} an die erste Position verschoben" 4 | moved_up: "%{resource} nach oben verschoben" 5 | moved_down: "%{resource} nach unten verschoben" 6 | moved_to_bottom: "%{resource} an die letzte Position verschoben" 7 | illegal_move_to_top: "Konnte %{resource} nicht n die erste Position verschieben" 8 | illegal_move_up: "Konnte %{resource} nicht nach oben verschieben" 9 | illegal_move_down: "Konnte %{resource} nicht nach unten verschieben" 10 | illegal_move_to_bottom: "Konnte %{resource} nicht n die letzte Position verschieben" 11 | -------------------------------------------------------------------------------- /config/locales/active_admin-awesome_nested_set.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | awesome_nested_set: 3 | moved_to_top: "%{resource} shifted to the first position" 4 | moved_up: "%{resource} shifted upward" 5 | moved_down: "%{resource} shifted downward" 6 | moved_to_bottom: "%{resource} moved to the last position" 7 | illegal_move_to_top: "%{resource} could not be moved to the first position" 8 | illegal_move_up: "%{resource} could not be moved upward" 9 | illegal_move_down: "%{resource} could not be moved downward" 10 | illegal_move_to_bottom: "%{resource} could not be moved to the last position" 11 | -------------------------------------------------------------------------------- /config/locales/active_admin-awesome_nested_set.ru.yml: -------------------------------------------------------------------------------- 1 | ru: 2 | awesome_nested_set: 3 | moved_to_top: "%{resource} перемещен(a) на первую позицию" 4 | moved_up: "%{resource} перемещен(a) вверх" 5 | moved_down: "%{resource} перемещен(a) вниз" 6 | moved_to_bottom: "%{resource} перемещен(a) на последнюю позицию" 7 | illegal_move_to_top: "%{resource} переместить на первую позицию не удалось" 8 | illegal_move_up: "%{resource} переместить вверх не удалось" 9 | illegal_move_down: "%{resource} переместить вниз не удалось" 10 | illegal_move_to_bottom: "%{resource} переместить на последнюю позицию не удалось" 11 | -------------------------------------------------------------------------------- /lib/active_admin-awesome_nested_set.rb: -------------------------------------------------------------------------------- 1 | require 'active_admin' 2 | 3 | require 'active_admin/awesome_nested_set/engine' 4 | require 'active_admin/awesome_nested_set/version' 5 | require 'active_admin/awesome_nested_set/helper' 6 | require 'active_admin/views/index_as_nested_set' 7 | 8 | module ActiveAdminActsAsAwesomeNestedSet 9 | end 10 | 11 | ActiveAdmin::ResourceDSL.send :include, ActiveAdmin::AwesomeNestedSet::Helper 12 | ActiveAdmin::Views::IndexAsTable.send :include, ActiveAdmin::AwesomeNestedSet::Helper 13 | ActiveAdmin::Views::Pages::Show.send :include, ActiveAdmin::AwesomeNestedSet::Helper 14 | -------------------------------------------------------------------------------- /lib/active_admin/awesome_nested_set/engine.rb: -------------------------------------------------------------------------------- 1 | module ActiveAdmin 2 | module AwesomeNestedSet 3 | class Engine < Rails::Engine 4 | paths["config/locales"] << File.dirname(__FILE__) + '/../../../config/locales' 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/active_admin/awesome_nested_set/helper.rb: -------------------------------------------------------------------------------- 1 | module ActiveAdmin 2 | module AwesomeNestedSet 3 | module Helper 4 | # Call this inside your index do...end block to make a column indented 5 | # for improved readability. 6 | # 7 | # Requires 'depth' be included in the resource 8 | # 9 | # Example: 10 | # 11 | # #app/admin/players.rb 12 | # 13 | # ActiveAdmin.register Player do 14 | # index do 15 | # #... 16 | # # This indents the firstname column based upon the :depth property 17 | # sortable_tree_indented_column :firstname 18 | # column :lastname 19 | # #... 20 | # end 21 | # end 22 | def sortable_tree_indented_column column_name 23 | column column_name do |resource| 24 | if resource.respond_to?("depth") 25 | "• #{resource[column_name]}".html_safe 26 | else 27 | resource[column_name] 28 | end 29 | end 30 | end 31 | 32 | # Call this inside your index do...end block to make your resource sortable. 33 | # 34 | # Example: 35 | # 36 | # #app/admin/players.rb 37 | # 38 | # ActiveAdmin.register Player do 39 | # index do 40 | # # This adds columns for moving up and down. 41 | # sortable_tree_columns 42 | # #... 43 | # column :firstname 44 | # column :lastname 45 | # default_actions 46 | # end 47 | # end 48 | def sortable_tree_columns 49 | column "▲".html_safe do |resource| 50 | link_to("▲".html_safe, self.send(:"move_up_#{ActiveAdmin.application.default_namespace}_#{resource.class.model_name.to_s.underscore.gsub("/", "_")}_path", resource), :class => "arrow") if resource.left_sibling 51 | end 52 | column "▼".html_safe do |resource| 53 | link_to("▼".html_safe, self.send(:"move_down_#{ActiveAdmin.application.default_namespace}_#{resource.class.model_name.to_s.underscore.gsub("/", "_")}_path", resource), :class => "arrow") if resource.right_sibling 54 | end 55 | end 56 | 57 | # Call this inside your resource definition to add the needed member actions 58 | # for your sortable resource. 59 | # 60 | # Example: 61 | # 62 | # #app/admin/players.rb 63 | # 64 | # ActiveAdmin.register Player do 65 | # # Sort players by position 66 | # config.sort_order = 'lft_asc' 67 | # 68 | # # Add member actions for positioning. 69 | # sortable_tree_member_actions 70 | # end 71 | def sortable_tree_member_actions 72 | member_action :move_up do 73 | unless resource.left_sibling 74 | redirect_to :back, :notice => I18n.t('awesome_nested_set.illegal_move_up', :resource => resource_class.to_s.camelize.constantize.model_name.human ) 75 | return 76 | end 77 | 78 | resource.move_left 79 | redirect_to :back, :notice => I18n.t('awesome_nested_set.moved_up', :resource => resource_class.to_s.camelize.constantize.model_name.human ) 80 | end 81 | 82 | member_action :move_down do 83 | unless resource.right_sibling 84 | redirect_to :back, :notice => I18n.t('awesome_nested_set.illegal_move_down', :resource => resource_class.to_s.camelize.constantize.model_name.human ) 85 | return 86 | end 87 | 88 | resource.move_right 89 | redirect_to :back, :notice => I18n.t('awesome_nested_set.moved_down', :resource => resource_class.to_s.camelize.constantize.model_name.human ) 90 | end 91 | end 92 | end 93 | end 94 | end 95 | 96 | -------------------------------------------------------------------------------- /lib/active_admin/awesome_nested_set/version.rb: -------------------------------------------------------------------------------- 1 | module ActiveAdmin 2 | module AwesomeNestedSet 3 | VERSION = "0.0.8" 4 | end 5 | end 6 | 7 | -------------------------------------------------------------------------------- /lib/active_admin/views/index_as_nested_set.rb: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | module ActiveAdmin 3 | module Views 4 | 5 | # = Index as a Nested Set 6 | # 7 | # Shows index page as a tree 8 | # 9 | # index :as => :nested_set do |product| 10 | # Another options for table 11 | # link_to(image_tag(product.image_path), admin_products_path(product)) 12 | # end 13 | # 14 | class IndexAsNestedSet < IndexAsTable 15 | 16 | def build(page_presenter, collection) 17 | super page_presenter, get_nested_set( resource_class ) 18 | end 19 | 20 | protected 21 | 22 | def get_nested_set class_or_item 23 | result = [] 24 | 25 | roots = class_or_item.respond_to?(:roots) ? class_or_item.roots : class_or_item 26 | 27 | items = roots.each do |root| 28 | result += root.self_and_descendants.to_a.compact 29 | end 30 | 31 | result 32 | end 33 | 34 | end 35 | end 36 | end 37 | 38 | -------------------------------------------------------------------------------- /lib/tasks/active_admin-awesome_nested_set_tasks.rake: -------------------------------------------------------------------------------- 1 | # desc "Explaining what the task does" 2 | # task :active_admin-awesome_nested_set do 3 | # # Task goes here 4 | # end 5 | -------------------------------------------------------------------------------- /spec/dummy/README.rdoc: -------------------------------------------------------------------------------- 1 | == Welcome to Rails 2 | 3 | Rails is a web-application framework that includes everything needed to create 4 | database-backed web applications according to the Model-View-Control pattern. 5 | 6 | This pattern splits the view (also called the presentation) into "dumb" 7 | templates that are primarily responsible for inserting pre-built data in between 8 | HTML tags. The model contains the "smart" domain objects (such as Account, 9 | Product, Person, Post) that holds all the business logic and knows how to 10 | persist themselves to a database. The controller handles the incoming requests 11 | (such as Save New Account, Update Product, Show Post) by manipulating the model 12 | and directing data to the view. 13 | 14 | In Rails, the model is handled by what's called an object-relational mapping 15 | layer entitled Active Record. This layer allows you to present the data from 16 | database rows as objects and embellish these data objects with business logic 17 | methods. You can read more about Active Record in 18 | link:files/vendor/rails/activerecord/README.html. 19 | 20 | The controller and view are handled by the Action Pack, which handles both 21 | layers by its two parts: Action View and Action Controller. These two layers 22 | are bundled in a single package due to their heavy interdependence. This is 23 | unlike the relationship between the Active Record and Action Pack that is much 24 | more separate. Each of these packages can be used independently outside of 25 | Rails. You can read more about Action Pack in 26 | link:files/vendor/rails/actionpack/README.html. 27 | 28 | 29 | == Getting Started 30 | 31 | 1. At the command prompt, create a new Rails application: 32 | rails new myapp (where myapp is the application name) 33 | 34 | 2. Change directory to myapp and start the web server: 35 | cd myapp; rails server (run with --help for options) 36 | 37 | 3. Go to http://localhost:3000/ and you'll see: 38 | "Welcome aboard: You're riding Ruby on Rails!" 39 | 40 | 4. Follow the guidelines to start developing your application. You can find 41 | the following resources handy: 42 | 43 | * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html 44 | * Ruby on Rails Tutorial Book: http://www.railstutorial.org/ 45 | 46 | 47 | == Debugging Rails 48 | 49 | Sometimes your application goes wrong. Fortunately there are a lot of tools that 50 | will help you debug it and get it back on the rails. 51 | 52 | First area to check is the application log files. Have "tail -f" commands 53 | running on the server.log and development.log. Rails will automatically display 54 | debugging and runtime information to these files. Debugging info will also be 55 | shown in the browser on requests from 127.0.0.1. 56 | 57 | You can also log your own messages directly into the log file from your code 58 | using the Ruby logger class from inside your controllers. Example: 59 | 60 | class WeblogController < ActionController::Base 61 | def destroy 62 | @weblog = Weblog.find(params[:id]) 63 | @weblog.destroy 64 | logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") 65 | end 66 | end 67 | 68 | The result will be a message in your log file along the lines of: 69 | 70 | Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! 71 | 72 | More information on how to use the logger is at http://www.ruby-doc.org/core/ 73 | 74 | Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are 75 | several books available online as well: 76 | 77 | * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) 78 | * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) 79 | 80 | These two books will bring you up to speed on the Ruby language and also on 81 | programming in general. 82 | 83 | 84 | == Debugger 85 | 86 | Debugger support is available through the debugger command when you start your 87 | Mongrel or WEBrick server with --debugger. This means that you can break out of 88 | execution at any point in the code, investigate and change the model, and then, 89 | resume execution! You need to install ruby-debug to run the server in debugging 90 | mode. With gems, use sudo gem install ruby-debug. Example: 91 | 92 | class WeblogController < ActionController::Base 93 | def index 94 | @posts = Post.all 95 | debugger 96 | end 97 | end 98 | 99 | So the controller will accept the action, run the first line, then present you 100 | with a IRB prompt in the server window. Here you can do things like: 101 | 102 | >> @posts.inspect 103 | => "[#nil, "body"=>nil, "id"=>"1"}>, 105 | #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" 107 | >> @posts.first.title = "hello from a debugger" 108 | => "hello from a debugger" 109 | 110 | ...and even better, you can examine how your runtime objects actually work: 111 | 112 | >> f = @posts.first 113 | => #nil, "body"=>nil, "id"=>"1"}> 114 | >> f. 115 | Display all 152 possibilities? (y or n) 116 | 117 | Finally, when you're ready to resume execution, you can enter "cont". 118 | 119 | 120 | == Console 121 | 122 | The console is a Ruby shell, which allows you to interact with your 123 | application's domain model. Here you'll have all parts of the application 124 | configured, just like it is when the application is running. You can inspect 125 | domain models, change values, and save to the database. Starting the script 126 | without arguments will launch it in the development environment. 127 | 128 | To start the console, run rails console from the application 129 | directory. 130 | 131 | Options: 132 | 133 | * Passing the -s, --sandbox argument will rollback any modifications 134 | made to the database. 135 | * Passing an environment name as an argument will load the corresponding 136 | environment. Example: rails console production. 137 | 138 | To reload your controllers and models after launching the console run 139 | reload! 140 | 141 | More information about irb can be found at: 142 | link:http://www.rubycentral.org/pickaxe/irb.html 143 | 144 | 145 | == dbconsole 146 | 147 | You can go to the command line of your database directly through rails 148 | dbconsole. You would be connected to the database with the credentials 149 | defined in database.yml. Starting the script without arguments will connect you 150 | to the development database. Passing an argument will connect you to a different 151 | database, like rails dbconsole production. Currently works for MySQL, 152 | PostgreSQL and SQLite 3. 153 | 154 | == Description of Contents 155 | 156 | The default directory structure of a generated Ruby on Rails application: 157 | 158 | |-- app 159 | | |-- assets 160 | | |-- images 161 | | |-- javascripts 162 | | `-- stylesheets 163 | | |-- controllers 164 | | |-- helpers 165 | | |-- mailers 166 | | |-- models 167 | | `-- views 168 | | `-- layouts 169 | |-- config 170 | | |-- environments 171 | | |-- initializers 172 | | `-- locales 173 | |-- db 174 | |-- doc 175 | |-- lib 176 | | `-- tasks 177 | |-- log 178 | |-- public 179 | |-- script 180 | |-- test 181 | | |-- fixtures 182 | | |-- functional 183 | | |-- integration 184 | | |-- performance 185 | | `-- unit 186 | |-- tmp 187 | | |-- cache 188 | | |-- pids 189 | | |-- sessions 190 | | `-- sockets 191 | `-- vendor 192 | |-- assets 193 | `-- stylesheets 194 | `-- plugins 195 | 196 | app 197 | Holds all the code that's specific to this particular application. 198 | 199 | app/assets 200 | Contains subdirectories for images, stylesheets, and JavaScript files. 201 | 202 | app/controllers 203 | Holds controllers that should be named like weblogs_controller.rb for 204 | automated URL mapping. All controllers should descend from 205 | ApplicationController which itself descends from ActionController::Base. 206 | 207 | app/models 208 | Holds models that should be named like post.rb. Models descend from 209 | ActiveRecord::Base by default. 210 | 211 | app/views 212 | Holds the template files for the view that should be named like 213 | weblogs/index.html.erb for the WeblogsController#index action. All views use 214 | eRuby syntax by default. 215 | 216 | app/views/layouts 217 | Holds the template files for layouts to be used with views. This models the 218 | common header/footer method of wrapping views. In your views, define a layout 219 | using the layout :default and create a file named default.html.erb. 220 | Inside default.html.erb, call <% yield %> to render the view using this 221 | layout. 222 | 223 | app/helpers 224 | Holds view helpers that should be named like weblogs_helper.rb. These are 225 | generated for you automatically when using generators for controllers. 226 | Helpers can be used to wrap functionality for your views into methods. 227 | 228 | config 229 | Configuration files for the Rails environment, the routing map, the database, 230 | and other dependencies. 231 | 232 | db 233 | Contains the database schema in schema.rb. db/migrate contains all the 234 | sequence of Migrations for your schema. 235 | 236 | doc 237 | This directory is where your application documentation will be stored when 238 | generated using rake doc:app 239 | 240 | lib 241 | Application specific libraries. Basically, any kind of custom code that 242 | doesn't belong under controllers, models, or helpers. This directory is in 243 | the load path. 244 | 245 | public 246 | The directory available for the web server. Also contains the dispatchers and the 247 | default HTML files. This should be set as the DOCUMENT_ROOT of your web 248 | server. 249 | 250 | script 251 | Helper scripts for automation and generation. 252 | 253 | test 254 | Unit and functional tests along with fixtures. When using the rails generate 255 | command, template test files will be generated for you and placed in this 256 | directory. 257 | 258 | vendor 259 | External libraries that the application depends on. Also includes the plugins 260 | subdirectory. If the app has frozen rails, those gems also go here, under 261 | vendor/rails/. This directory is in the load path. 262 | -------------------------------------------------------------------------------- /spec/dummy/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | # Add your own tasks in files placed in lib/tasks ending in .rake, 3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 4 | 5 | require File.expand_path('../config/application', __FILE__) 6 | 7 | Dummy::Application.load_tasks 8 | -------------------------------------------------------------------------------- /spec/dummy/app/admin/admin_users.rb: -------------------------------------------------------------------------------- 1 | ActiveAdmin.register AdminUser do 2 | index do 3 | column :email 4 | column :current_sign_in_at 5 | column :last_sign_in_at 6 | column :sign_in_count 7 | default_actions 8 | end 9 | 10 | filter :email 11 | 12 | form do |f| 13 | f.inputs "Admin Details" do 14 | f.input :email 15 | f.input :password 16 | f.input :password_confirmation 17 | end 18 | f.actions 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/dummy/app/admin/categories.rb: -------------------------------------------------------------------------------- 1 | ActiveAdmin.register Category do 2 | # Set the default sort order. 3 | config.sort_order = 'lft_asc' 4 | 5 | # Add member actions for positioning. 6 | sortable_tree_member_actions 7 | 8 | form do |f| 9 | f.inputs do 10 | f.input :parent 11 | f.input :name 12 | end # f.inputs 13 | f.actions 14 | end # form 15 | 16 | index do 17 | # This adds columns for moving up, down, top and bottom. 18 | sortable_tree_columns 19 | 20 | sortable_tree_indented_column :name 21 | default_actions 22 | end # index 23 | end # ActiveAdmin.register Category 24 | 25 | -------------------------------------------------------------------------------- /spec/dummy/app/admin/dashboard.rb: -------------------------------------------------------------------------------- 1 | ActiveAdmin.register_page "Dashboard" do 2 | 3 | menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") } 4 | 5 | content :title => proc{ I18n.t("active_admin.dashboard") } do 6 | div :class => "blank_slate_container", :id => "dashboard_default_message" do 7 | span :class => "blank_slate" do 8 | span I18n.t("active_admin.dashboard_welcome.welcome") 9 | small I18n.t("active_admin.dashboard_welcome.call_to_action") 10 | end 11 | end 12 | 13 | # Here is an example of a simple dashboard with columns and panels. 14 | # 15 | # columns do 16 | # column do 17 | # panel "Recent Posts" do 18 | # ul do 19 | # Post.recent(5).map do |post| 20 | # li link_to(post.title, admin_post_path(post)) 21 | # end 22 | # end 23 | # end 24 | # end 25 | 26 | # column do 27 | # panel "Info" do 28 | # para "Welcome to ActiveAdmin." 29 | # end 30 | # end 31 | # end 32 | end # content 33 | end 34 | -------------------------------------------------------------------------------- /spec/dummy/app/assets/javascripts/active_admin.js: -------------------------------------------------------------------------------- 1 | //= require active_admin/base 2 | -------------------------------------------------------------------------------- /spec/dummy/app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // the compiled file. 9 | // 10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD 11 | // GO AFTER THE REQUIRES BELOW. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require_tree . 16 | -------------------------------------------------------------------------------- /spec/dummy/app/assets/stylesheets/active_admin.css.scss: -------------------------------------------------------------------------------- 1 | // SASS variable overrides must be declared before loading up Active Admin's styles. 2 | // 3 | // To view the variables that Active Admin provides, take a look at 4 | // `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the 5 | // Active Admin source. 6 | // 7 | // For example, to change the sidebar width: 8 | // $sidebar-width: 242px; 9 | 10 | // Active Admin's got SASS! 11 | @import "active_admin/mixins"; 12 | @import "active_admin/base"; 13 | 14 | // Overriding any non-variable SASS must be done after the fact. 15 | // For example, to change the default status-tag color: 16 | // 17 | // body.active_admin { 18 | // .status_tag { background: #6090DB; } 19 | // } 20 | // 21 | // Notice that Active Admin CSS rules are nested within a 22 | // 'body.active_admin' selector to prevent conflicts with 23 | // other pages in the app. It is best to wrap your changes in a 24 | // namespace so they are properly recognized. You have options 25 | // if you e.g. want different styles for different namespaces: 26 | // 27 | // .active_admin applies to any Active Admin namespace 28 | // .admin_namespace applies to the admin namespace (eg: /admin) 29 | // .other_namespace applies to a custom namespace named other (eg: /other) 30 | -------------------------------------------------------------------------------- /spec/dummy/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require_self 12 | *= require_tree . 13 | */ 14 | -------------------------------------------------------------------------------- /spec/dummy/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | end 4 | -------------------------------------------------------------------------------- /spec/dummy/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /spec/dummy/app/mailers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotex82/active_admin-awesome_nested_set/7e2d97e819dea162c05f16d70780cb7f37200cef/spec/dummy/app/mailers/.gitkeep -------------------------------------------------------------------------------- /spec/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotex82/active_admin-awesome_nested_set/7e2d97e819dea162c05f16d70780cb7f37200cef/spec/dummy/app/models/.gitkeep -------------------------------------------------------------------------------- /spec/dummy/app/models/admin_user.rb: -------------------------------------------------------------------------------- 1 | class AdminUser < ActiveRecord::Base 2 | # Include default devise modules. Others available are: 3 | # :token_authenticatable, :confirmable, 4 | # :lockable, :timeoutable and :omniauthable 5 | devise :database_authenticatable, 6 | :recoverable, :rememberable, :trackable, :validatable 7 | 8 | # Setup accessible (or protected) attributes for your model 9 | attr_accessible :email, :password, :password_confirmation, :remember_me 10 | # attr_accessible :title, :body 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy/app/models/category.rb: -------------------------------------------------------------------------------- 1 | class Category < ActiveRecord::Base 2 | # attributes 3 | attr_accessible :name, 4 | :parent_id 5 | 6 | # tree support 7 | acts_as_nested_set 8 | default_scope :order => 'lft ASC' 9 | 10 | # validations 11 | validates :name, :presence => true 12 | end 13 | 14 | -------------------------------------------------------------------------------- /spec/dummy/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Dummy 5 | <%= stylesheet_link_tag "application", :media => "all" %> 6 | <%= javascript_include_tag "application" %> 7 | <%= csrf_meta_tags %> 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spec/dummy/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Dummy::Application 5 | -------------------------------------------------------------------------------- /spec/dummy/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | # Pick the frameworks you want: 4 | require "active_record/railtie" 5 | require "action_controller/railtie" 6 | require "action_mailer/railtie" 7 | require "active_resource/railtie" 8 | require "sprockets/railtie" 9 | # require "rails/test_unit/railtie" 10 | 11 | require "active_admin" 12 | require "awesome_nested_set" 13 | require "active_admin-awesome_nested_set" 14 | # Bundler.require 15 | 16 | 17 | module Dummy 18 | class Application < Rails::Application 19 | # Settings in config/environments/* take precedence over those specified here. 20 | # Application configuration should go into files in config/initializers 21 | # -- all .rb files in that directory are automatically loaded. 22 | 23 | # Custom directories with classes and modules you want to be autoloadable. 24 | # config.autoload_paths += %W(#{config.root}/extras) 25 | 26 | # Only load the plugins named here, in the order given (default is alphabetical). 27 | # :all can be used as a placeholder for all plugins not explicitly named. 28 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 29 | 30 | # Activate observers that should always be running. 31 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer 32 | 33 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 34 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 35 | # config.time_zone = 'Central Time (US & Canada)' 36 | 37 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 38 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 39 | # config.i18n.default_locale = :de 40 | 41 | # Configure the default encoding used in templates for Ruby 1.9. 42 | config.encoding = "utf-8" 43 | 44 | # Configure sensitive parameters which will be filtered from the log file. 45 | config.filter_parameters += [:password] 46 | 47 | # Enable escaping HTML in JSON. 48 | config.active_support.escape_html_entities_in_json = true 49 | 50 | # Use SQL instead of Active Record's schema dumper when creating the database. 51 | # This is necessary if your schema can't be completely dumped by the schema dumper, 52 | # like if you have constraints or database-specific column types 53 | # config.active_record.schema_format = :sql 54 | 55 | # Enforce whitelist mode for mass assignment. 56 | # This will create an empty whitelist of attributes available for mass-assignment for all models 57 | # in your app. As such, your models will need to explicitly whitelist or blacklist accessible 58 | # parameters by using an attr_accessible or attr_protected declaration. 59 | config.active_record.whitelist_attributes = true 60 | 61 | # Enable the asset pipeline 62 | config.assets.enabled = true 63 | 64 | # Version of your assets, change this if you want to expire all your assets 65 | config.assets.version = '1.0' 66 | 67 | config.generators do |g| 68 | g.test_framework :rspec, :fixture_replacement => :factory_girl 69 | end 70 | end 71 | end 72 | 73 | -------------------------------------------------------------------------------- /spec/dummy/config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | gemfile = File.expand_path('../../../../Gemfile', __FILE__) 3 | 4 | if File.exist?(gemfile) 5 | ENV['BUNDLE_GEMFILE'] = gemfile 6 | require 'bundler' 7 | Bundler.setup 8 | end 9 | 10 | $:.unshift File.expand_path('../../../../lib', __FILE__) -------------------------------------------------------------------------------- /spec/dummy/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | development: 7 | adapter: sqlite3 8 | database: db/development.sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | # Warning: The database defined as "test" will be erased and 13 | # re-generated from your development database when you run "rake". 14 | # Do not set this db to the same as development or production. 15 | test: 16 | adapter: sqlite3 17 | database: db/test.sqlite3 18 | pool: 5 19 | timeout: 5000 20 | 21 | production: 22 | adapter: sqlite3 23 | database: db/production.sqlite3 24 | pool: 5 25 | timeout: 5000 26 | -------------------------------------------------------------------------------- /spec/dummy/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | Dummy::Application.initialize! 6 | -------------------------------------------------------------------------------- /spec/dummy/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger 20 | config.active_support.deprecation = :log 21 | 22 | # Only use best-standards-support built into browsers 23 | config.action_dispatch.best_standards_support = :builtin 24 | 25 | # Raise exception on mass assignment protection for Active Record models 26 | config.active_record.mass_assignment_sanitizer = :strict 27 | 28 | # Log the query plan for queries taking more than this (works 29 | # with SQLite, MySQL, and PostgreSQL) 30 | config.active_record.auto_explain_threshold_in_seconds = 0.5 31 | 32 | # Do not compress assets 33 | config.assets.compress = false 34 | 35 | # Expands the lines which load the assets 36 | config.assets.debug = true 37 | end 38 | -------------------------------------------------------------------------------- /spec/dummy/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # Code is not reloaded between requests 5 | config.cache_classes = true 6 | 7 | # Full error reports are disabled and caching is turned on 8 | config.consider_all_requests_local = false 9 | config.action_controller.perform_caching = true 10 | 11 | # Disable Rails's static asset server (Apache or nginx will already do this) 12 | config.serve_static_assets = false 13 | 14 | # Compress JavaScripts and CSS 15 | config.assets.compress = true 16 | 17 | # Don't fallback to assets pipeline if a precompiled asset is missed 18 | config.assets.compile = false 19 | 20 | # Generate digests for assets URLs 21 | config.assets.digest = true 22 | 23 | # Defaults to nil and saved in location specified by config.assets.prefix 24 | # config.assets.manifest = YOUR_PATH 25 | 26 | # Specifies the header that your server uses for sending files 27 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 28 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 29 | 30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 31 | # config.force_ssl = true 32 | 33 | # See everything in the log (default is :info) 34 | # config.log_level = :debug 35 | 36 | # Prepend all log lines with the following tags 37 | # config.log_tags = [ :subdomain, :uuid ] 38 | 39 | # Use a different logger for distributed setups 40 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 41 | 42 | # Use a different cache store in production 43 | # config.cache_store = :mem_cache_store 44 | 45 | # Enable serving of images, stylesheets, and JavaScripts from an asset server 46 | # config.action_controller.asset_host = "http://assets.example.com" 47 | 48 | # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) 49 | # config.assets.precompile += %w( search.js ) 50 | 51 | # Disable delivery errors, bad email addresses will be ignored 52 | # config.action_mailer.raise_delivery_errors = false 53 | 54 | # Enable threaded mode 55 | # config.threadsafe! 56 | 57 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 58 | # the I18n.default_locale when a translation can not be found) 59 | config.i18n.fallbacks = true 60 | 61 | # Send deprecation notices to registered listeners 62 | config.active_support.deprecation = :notify 63 | 64 | # Log the query plan for queries taking more than this (works 65 | # with SQLite, MySQL, and PostgreSQL) 66 | # config.active_record.auto_explain_threshold_in_seconds = 0.5 67 | end 68 | -------------------------------------------------------------------------------- /spec/dummy/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Configure static asset server for tests with Cache-Control for performance 11 | config.serve_static_assets = true 12 | config.static_cache_control = "public, max-age=3600" 13 | 14 | # Log error messages when you accidentally call methods on nil 15 | config.whiny_nils = true 16 | 17 | # Show full error reports and disable caching 18 | config.consider_all_requests_local = true 19 | config.action_controller.perform_caching = false 20 | 21 | # Raise exceptions instead of rendering exception templates 22 | config.action_dispatch.show_exceptions = false 23 | 24 | # Disable request forgery protection in test environment 25 | config.action_controller.allow_forgery_protection = false 26 | 27 | # Tell Action Mailer not to deliver emails to the real world. 28 | # The :test delivery method accumulates sent emails in the 29 | # ActionMailer::Base.deliveries array. 30 | config.action_mailer.delivery_method = :test 31 | 32 | # Raise exception on mass assignment protection for Active Record models 33 | config.active_record.mass_assignment_sanitizer = :strict 34 | 35 | # Print deprecation notices to the stderr 36 | config.active_support.deprecation = :stderr 37 | end 38 | -------------------------------------------------------------------------------- /spec/dummy/config/initializers/active_admin.rb: -------------------------------------------------------------------------------- 1 | ActiveAdmin.setup do |config| 2 | 3 | # == Site Title 4 | # 5 | # Set the title that is displayed on the main layout 6 | # for each of the active admin pages. 7 | # 8 | config.site_title = "Dummy" 9 | 10 | # Set the link url for the title. For example, to take 11 | # users to your main site. Defaults to no link. 12 | # 13 | # config.site_title_link = "/" 14 | 15 | # Set an optional image to be displayed for the header 16 | # instead of a string (overrides :site_title) 17 | # 18 | # Note: Recommended image height is 21px to properly fit in the header 19 | # 20 | # config.site_title_image = "/images/logo.png" 21 | 22 | # == Default Namespace 23 | # 24 | # Set the default namespace each administration resource 25 | # will be added to. 26 | # 27 | # eg: 28 | # config.default_namespace = :hello_world 29 | # 30 | # This will create resources in the HelloWorld module and 31 | # will namespace routes to /hello_world/* 32 | # 33 | # To set no namespace by default, use: 34 | # config.default_namespace = false 35 | # 36 | # Default: 37 | # config.default_namespace = :admin 38 | # 39 | # You can customize the settings for each namespace by using 40 | # a namespace block. For example, to change the site title 41 | # within a namespace: 42 | # 43 | # config.namespace :admin do |admin| 44 | # admin.site_title = "Custom Admin Title" 45 | # end 46 | # 47 | # This will ONLY change the title for the admin section. Other 48 | # namespaces will continue to use the main "site_title" configuration. 49 | 50 | # == User Authentication 51 | # 52 | # Active Admin will automatically call an authentication 53 | # method in a before filter of all controller actions to 54 | # ensure that there is a currently logged in admin user. 55 | # 56 | # This setting changes the method which Active Admin calls 57 | # within the controller. 58 | config.authentication_method = :authenticate_admin_user! 59 | 60 | 61 | # == Current User 62 | # 63 | # Active Admin will associate actions with the current 64 | # user performing them. 65 | # 66 | # This setting changes the method which Active Admin calls 67 | # to return the currently logged in user. 68 | config.current_user_method = :current_admin_user 69 | 70 | 71 | # == Logging Out 72 | # 73 | # Active Admin displays a logout link on each screen. These 74 | # settings configure the location and method used for the link. 75 | # 76 | # This setting changes the path where the link points to. If it's 77 | # a string, the strings is used as the path. If it's a Symbol, we 78 | # will call the method to return the path. 79 | # 80 | # Default: 81 | config.logout_link_path = :destroy_admin_user_session_path 82 | 83 | # This setting changes the http method used when rendering the 84 | # link. For example :get, :delete, :put, etc.. 85 | # 86 | # Default: 87 | # config.logout_link_method = :get 88 | 89 | # == Root 90 | # 91 | # Set the action to call for the root path. You can set different 92 | # roots for each namespace. 93 | # 94 | # Default: 95 | # config.root_to = 'dashboard#index' 96 | 97 | # == Admin Comments 98 | # 99 | # Admin comments allow you to add comments to any model for admin use. 100 | # Admin comments are enabled by default. 101 | # 102 | # Default: 103 | # config.allow_comments = true 104 | # 105 | # You can turn them on and off for any given namespace by using a 106 | # namespace config block. 107 | # 108 | # Eg: 109 | # config.namespace :without_comments do |without_comments| 110 | # without_comments.allow_comments = false 111 | # end 112 | 113 | 114 | # == Batch Actions 115 | # 116 | # Enable and disable Batch Actions 117 | # 118 | config.batch_actions = true 119 | 120 | 121 | # == Controller Filters 122 | # 123 | # You can add before, after and around filters to all of your 124 | # Active Admin resources and pages from here. 125 | # 126 | # config.before_filter :do_something_awesome 127 | 128 | 129 | # == Register Stylesheets & Javascripts 130 | # 131 | # We recommend using the built in Active Admin layout and loading 132 | # up your own stylesheets / javascripts to customize the look 133 | # and feel. 134 | # 135 | # To load a stylesheet: 136 | # config.register_stylesheet 'my_stylesheet.css' 137 | 138 | # You can provide an options hash for more control, which is passed along to stylesheet_link_tag(): 139 | # config.register_stylesheet 'my_print_stylesheet.css', :media => :print 140 | # 141 | # To load a javascript file: 142 | # config.register_javascript 'my_javascript.js' 143 | 144 | 145 | # == CSV options 146 | # 147 | # Set the CSV builder separator (default is ",") 148 | # config.csv_column_separator = ',' 149 | # 150 | # Set the CSV builder options (default is {}) 151 | # config.csv_options = {} 152 | end 153 | -------------------------------------------------------------------------------- /spec/dummy/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /spec/dummy/config/initializers/devise.rb: -------------------------------------------------------------------------------- 1 | # Use this hook to configure devise mailer, warden hooks and so forth. 2 | # Many of these configuration options can be set straight in your model. 3 | Devise.setup do |config| 4 | # ==> Mailer Configuration 5 | # Configure the e-mail address which will be shown in Devise::Mailer, 6 | # note that it will be overwritten if you use your own mailer class with default "from" parameter. 7 | config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" 8 | 9 | # Configure the class responsible to send e-mails. 10 | # config.mailer = "Devise::Mailer" 11 | 12 | # ==> ORM configuration 13 | # Load and configure the ORM. Supports :active_record (default) and 14 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 15 | # available as additional gems. 16 | require 'devise/orm/active_record' 17 | 18 | # ==> Configuration for any authentication mechanism 19 | # Configure which keys are used when authenticating a user. The default is 20 | # just :email. You can configure it to use [:username, :subdomain], so for 21 | # authenticating a user, both parameters are required. Remember that those 22 | # parameters are used only when authenticating and not when retrieving from 23 | # session. If you need permissions, you should implement that in a before filter. 24 | # You can also supply a hash where the value is a boolean determining whether 25 | # or not authentication should be aborted when the value is not present. 26 | # config.authentication_keys = [ :email ] 27 | 28 | # Configure parameters from the request object used for authentication. Each entry 29 | # given should be a request method and it will automatically be passed to the 30 | # find_for_authentication method and considered in your model lookup. For instance, 31 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 32 | # The same considerations mentioned for authentication_keys also apply to request_keys. 33 | # config.request_keys = [] 34 | 35 | # Configure which authentication keys should be case-insensitive. 36 | # These keys will be downcased upon creating or modifying a user and when used 37 | # to authenticate or find a user. Default is :email. 38 | config.case_insensitive_keys = [ :email ] 39 | 40 | # Configure which authentication keys should have whitespace stripped. 41 | # These keys will have whitespace before and after removed upon creating or 42 | # modifying a user and when used to authenticate or find a user. Default is :email. 43 | config.strip_whitespace_keys = [ :email ] 44 | 45 | # Tell if authentication through request.params is enabled. True by default. 46 | # It can be set to an array that will enable params authentication only for the 47 | # given strategies, for example, `config.params_authenticatable = [:database]` will 48 | # enable it only for database (email + password) authentication. 49 | # config.params_authenticatable = true 50 | 51 | # Tell if authentication through HTTP Basic Auth is enabled. False by default. 52 | # It can be set to an array that will enable http authentication only for the 53 | # given strategies, for example, `config.http_authenticatable = [:token]` will 54 | # enable it only for token authentication. 55 | # config.http_authenticatable = false 56 | 57 | # If http headers should be returned for AJAX requests. True by default. 58 | # config.http_authenticatable_on_xhr = true 59 | 60 | # The realm used in Http Basic Authentication. "Application" by default. 61 | # config.http_authentication_realm = "Application" 62 | 63 | # It will change confirmation, password recovery and other workflows 64 | # to behave the same regardless if the e-mail provided was right or wrong. 65 | # Does not affect registerable. 66 | # config.paranoid = true 67 | 68 | # By default Devise will store the user in session. You can skip storage for 69 | # :http_auth and :token_auth by adding those symbols to the array below. 70 | # Notice that if you are skipping storage for all authentication paths, you 71 | # may want to disable generating routes to Devise's sessions controller by 72 | # passing :skip => :sessions to `devise_for` in your config/routes.rb 73 | config.skip_session_storage = [:http_auth] 74 | 75 | # ==> Configuration for :database_authenticatable 76 | # For bcrypt, this is the cost for hashing the password and defaults to 10. If 77 | # using other encryptors, it sets how many times you want the password re-encrypted. 78 | # 79 | # Limiting the stretches to just one in testing will increase the performance of 80 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 81 | # a value less than 10 in other environments. 82 | config.stretches = Rails.env.test? ? 1 : 10 83 | 84 | # Setup a pepper to generate the encrypted password. 85 | # config.pepper = "6fb5ec58c114603c82d1edbf7949032c66a29bf80b0df7faf72d4be505291470e77c3551fc43c0d6d53bf70a9ac1883e6dc2b293fc2bb749b4b4ccbcdb15196e" 86 | 87 | # ==> Configuration for :confirmable 88 | # A period that the user is allowed to access the website even without 89 | # confirming his account. For instance, if set to 2.days, the user will be 90 | # able to access the website for two days without confirming his account, 91 | # access will be blocked just in the third day. Default is 0.days, meaning 92 | # the user cannot access the website without confirming his account. 93 | # config.allow_unconfirmed_access_for = 2.days 94 | 95 | # A period that the user is allowed to confirm their account before their 96 | # token becomes invalid. For example, if set to 3.days, the user can confirm 97 | # their account within 3 days after the mail was sent, but on the fourth day 98 | # their account can't be confirmed with the token any more. 99 | # Default is nil, meaning there is no restriction on how long a user can take 100 | # before confirming their account. 101 | # config.confirm_within = 3.days 102 | 103 | # If true, requires any email changes to be confirmed (exactly the same way as 104 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 105 | # db field (see migrations). Until confirmed new email is stored in 106 | # unconfirmed email column, and copied to email column on successful confirmation. 107 | config.reconfirmable = true 108 | 109 | # Defines which key will be used when confirming an account 110 | # config.confirmation_keys = [ :email ] 111 | 112 | # ==> Configuration for :rememberable 113 | # The time the user will be remembered without asking for credentials again. 114 | # config.remember_for = 2.weeks 115 | 116 | # If true, extends the user's remember period when remembered via cookie. 117 | # config.extend_remember_period = false 118 | 119 | # Options to be passed to the created cookie. For instance, you can set 120 | # :secure => true in order to force SSL only cookies. 121 | # config.rememberable_options = {} 122 | 123 | # ==> Configuration for :validatable 124 | # Range for password length. Default is 8..128. 125 | config.password_length = 8..128 126 | 127 | # Email regex used to validate email formats. It simply asserts that 128 | # an one (and only one) @ exists in the given string. This is mainly 129 | # to give user feedback and not to assert the e-mail validity. 130 | # config.email_regexp = /\A[^@]+@[^@]+\z/ 131 | 132 | # ==> Configuration for :timeoutable 133 | # The time you want to timeout the user session without activity. After this 134 | # time the user will be asked for credentials again. Default is 30 minutes. 135 | # config.timeout_in = 30.minutes 136 | 137 | # If true, expires auth token on session timeout. 138 | # config.expire_auth_token_on_timeout = false 139 | 140 | # ==> Configuration for :lockable 141 | # Defines which strategy will be used to lock an account. 142 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 143 | # :none = No lock strategy. You should handle locking by yourself. 144 | # config.lock_strategy = :failed_attempts 145 | 146 | # Defines which key will be used when locking and unlocking an account 147 | # config.unlock_keys = [ :email ] 148 | 149 | # Defines which strategy will be used to unlock an account. 150 | # :email = Sends an unlock link to the user email 151 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 152 | # :both = Enables both strategies 153 | # :none = No unlock strategy. You should handle unlocking by yourself. 154 | # config.unlock_strategy = :both 155 | 156 | # Number of authentication tries before locking an account if lock_strategy 157 | # is failed attempts. 158 | # config.maximum_attempts = 20 159 | 160 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 161 | # config.unlock_in = 1.hour 162 | 163 | # ==> Configuration for :recoverable 164 | # 165 | # Defines which key will be used when recovering the password for an account 166 | # config.reset_password_keys = [ :email ] 167 | 168 | # Time interval you can reset your password with a reset password key. 169 | # Don't put a too small interval or your users won't have the time to 170 | # change their passwords. 171 | config.reset_password_within = 6.hours 172 | 173 | # ==> Configuration for :encryptable 174 | # Allow you to use another encryption algorithm besides bcrypt (default). You can use 175 | # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, 176 | # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) 177 | # and :restful_authentication_sha1 (then you should set stretches to 10, and copy 178 | # REST_AUTH_SITE_KEY to pepper) 179 | # config.encryptor = :sha512 180 | 181 | # ==> Configuration for :token_authenticatable 182 | # Defines name of the authentication token params key 183 | # config.token_authentication_key = :auth_token 184 | 185 | # ==> Scopes configuration 186 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 187 | # "users/sessions/new". It's turned off by default because it's slower if you 188 | # are using only default views. 189 | # config.scoped_views = false 190 | 191 | # Configure the default scope given to Warden. By default it's the first 192 | # devise role declared in your routes (usually :user). 193 | # config.default_scope = :user 194 | 195 | # Set this configuration to false if you want /users/sign_out to sign out 196 | # only the current scope. By default, Devise signs out all scopes. 197 | # config.sign_out_all_scopes = true 198 | 199 | # ==> Navigation configuration 200 | # Lists the formats that should be treated as navigational. Formats like 201 | # :html, should redirect to the sign in page when the user does not have 202 | # access, but formats like :xml or :json, should return 401. 203 | # 204 | # If you have any extra navigational formats, like :iphone or :mobile, you 205 | # should add them to the navigational formats lists. 206 | # 207 | # The "*/*" below is required to match Internet Explorer requests. 208 | # config.navigational_formats = ["*/*", :html] 209 | 210 | # The default HTTP method used to sign out a resource. Default is :delete. 211 | config.sign_out_via = :delete 212 | 213 | # ==> OmniAuth 214 | # Add a new OmniAuth provider. Check the wiki for more information on setting 215 | # up on your models and hooks. 216 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' 217 | 218 | # ==> Warden configuration 219 | # If you want to use other strategies, that are not supported by Devise, or 220 | # change the failure app, you can configure them inside the config.warden block. 221 | # 222 | # config.warden do |manager| 223 | # manager.intercept_401 = false 224 | # manager.default_strategies(:scope => :user).unshift :some_external_strategy 225 | # end 226 | 227 | # ==> Mountable engine configurations 228 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 229 | # is mountable, there are some extra configurations to be taken into account. 230 | # The following options are available, assuming the engine is mounted as: 231 | # 232 | # mount MyEngine, at: "/my_engine" 233 | # 234 | # The router that invoked `devise_for`, in the example above, would be: 235 | # config.router_name = :my_engine 236 | # 237 | # When using omniauth, Devise cannot automatically set Omniauth path, 238 | # so you need to do it manually. For the users scope, it would be: 239 | # config.omniauth_path_prefix = "/my_engine/users/auth" 240 | end 241 | -------------------------------------------------------------------------------- /spec/dummy/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | # 12 | # These inflection rules are supported but not enabled by default: 13 | # ActiveSupport::Inflector.inflections do |inflect| 14 | # inflect.acronym 'RESTful' 15 | # end 16 | -------------------------------------------------------------------------------- /spec/dummy/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /spec/dummy/config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | # Make sure the secret is at least 30 characters and all random, 6 | # no regular words or you'll be exposed to dictionary attacks. 7 | Dummy::Application.config.secret_token = 'e3377705fe77beb55fda9f7993267ed726a87290a905bd6f90218ab05ea8b6ae6b6cd3f0f4269b9bb25171d0031613469974b0e8e9ed8429cd45157e06295045' 8 | -------------------------------------------------------------------------------- /spec/dummy/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session' 4 | 5 | # Use the database for sessions instead of the cookie-based default, 6 | # which shouldn't be used to store highly confidential information 7 | # (create the session table with "rails generate session_migration") 8 | # Dummy::Application.config.session_store :active_record_store 9 | -------------------------------------------------------------------------------- /spec/dummy/config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters :format => [:json] 9 | end 10 | 11 | # Disable root element in JSON by default. 12 | ActiveSupport.on_load(:active_record) do 13 | self.include_root_in_json = false 14 | end 15 | -------------------------------------------------------------------------------- /spec/dummy/config/locales/active_admin.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | active_admin: 3 | dashboard: Dashboard 4 | dashboard_welcome: 5 | welcome: "Welcome to Active Admin. This is the default dashboard page." 6 | call_to_action: "To add dashboard sections, checkout 'app/admin/dashboards.rb'" 7 | view: "View" 8 | edit: "Edit" 9 | delete: "Delete" 10 | delete_confirmation: "Are you sure you want to delete this?" 11 | new_model: "New %{model}" 12 | create_model: "New %{model}" 13 | edit_model: "Edit %{model}" 14 | update_model: "Edit %{model}" 15 | delete_model: "Delete %{model}" 16 | details: "%{model} Details" 17 | cancel: "Cancel" 18 | empty: "Empty" 19 | previous: "Previous" 20 | next: "Next" 21 | download: "Download:" 22 | has_many_new: "Add New %{model}" 23 | has_many_delete: "Delete" 24 | filter: "Filter" 25 | clear_filters: "Clear Filters" 26 | search_field: "Search %{field}" 27 | equal_to: "Equal To" 28 | greater_than: "Greater Than" 29 | less_than: "Less Than" 30 | main_content: "Please implement %{model}#main_content to display content." 31 | logout: "Logout" 32 | powered_by: "Powered by %{active_admin} %{version}" 33 | sidebars: 34 | filters: "Filters" 35 | pagination: 36 | empty: "No %{model} found" 37 | one: "Displaying 1 %{model}" 38 | one_page: "Displaying all %{n} %{model}" 39 | multiple: "Displaying %{model} %{from} - %{to} of %{total} in total" 40 | entry: 41 | one: "entry" 42 | other: "entries" 43 | any: "Any" 44 | blank_slate: 45 | content: "There are no %{resource_name} yet." 46 | link: "Create one" 47 | batch_actions: 48 | button_label: "Batch Actions" 49 | delete_confirmation: "Are you sure you want to delete these %{plural_model}? You won't be able to undo this." 50 | succesfully_destroyed: 51 | one: "Successfully destroyed 1 %{model}" 52 | other: "Successfully destroyed %{count} %{plural_model}" 53 | selection_toggle_explanation: "(Toggle Selection)" 54 | link: "Create one" 55 | action_label: "%{title} Selected" 56 | labels: 57 | destroy: "Delete" 58 | comments: 59 | body: "Body" 60 | author: "Author" 61 | title: "Comment" 62 | add: "Add Comment" 63 | resource: "Resource" 64 | no_comments_yet: "No comments yet." 65 | title_content: "Comments (%{count})" 66 | errors: 67 | empty_text: "Comment wasn't saved, text was empty." 68 | devise: 69 | login: 70 | title: "Login" 71 | remember_me: "Remember me" 72 | submit: "Login" 73 | reset_password: 74 | title: "Forgot your password?" 75 | submit: "Reset My Password" 76 | change_password: 77 | title: "Change your password" 78 | submit: "Change my password" 79 | links: 80 | sign_in: "Sign in" 81 | forgot_your_password: "Forgot your password?" 82 | 83 | -------------------------------------------------------------------------------- /spec/dummy/config/locales/devise.en.yml: -------------------------------------------------------------------------------- 1 | # Additional translations at https://github.com/plataformatec/devise/wiki/I18n 2 | 3 | en: 4 | devise: 5 | confirmations: 6 | confirmed: "Your account was successfully confirmed. You are now signed in." 7 | send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes." 8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes." 9 | failure: 10 | already_authenticated: "You are already signed in." 11 | inactive: "Your account was not activated yet." 12 | invalid: "Invalid email or password." 13 | invalid_token: "Invalid authentication token." 14 | locked: "Your account is locked." 15 | not_found_in_database: "Invalid email or password." 16 | timeout: "Your session expired, please sign in again to continue." 17 | unauthenticated: "You need to sign in or sign up before continuing." 18 | unconfirmed: "You have to confirm your account before continuing." 19 | mailer: 20 | confirmation_instructions: 21 | subject: "Confirmation instructions" 22 | reset_password_instructions: 23 | subject: "Reset password instructions" 24 | unlock_instructions: 25 | subject: "Unlock Instructions" 26 | omniauth_callbacks: 27 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"." 28 | success: "Successfully authenticated from %{kind} account." 29 | passwords: 30 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." 31 | send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes." 32 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." 33 | updated: "Your password was changed successfully. You are now signed in." 34 | updated_not_active: "Your password was changed successfully." 35 | registrations: 36 | destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon." 37 | signed_up: "Welcome! You have signed up successfully." 38 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." 39 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." 40 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account." 41 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address." 42 | updated: "You updated your account successfully." 43 | sessions: 44 | signed_in: "Signed in successfully." 45 | signed_out: "Signed out successfully." 46 | unlocks: 47 | send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes." 48 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes." 49 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 50 | errors: 51 | messages: 52 | already_confirmed: "was already confirmed, please try signing in" 53 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 54 | expired: "has expired, please request a new one" 55 | not_found: "not found" 56 | not_locked: "was not locked" 57 | not_saved: 58 | one: "1 error prohibited this %{resource} from being saved:" 59 | other: "%{count} errors prohibited this %{resource} from being saved:" 60 | -------------------------------------------------------------------------------- /spec/dummy/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /spec/dummy/config/routes.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.routes.draw do 2 | ActiveAdmin.routes(self) 3 | 4 | devise_for :admin_users, ActiveAdmin::Devise.config 5 | 6 | # The priority is based upon order of creation: 7 | # first created -> highest priority. 8 | 9 | # Sample of regular route: 10 | # match 'products/:id' => 'catalog#view' 11 | # Keep in mind you can assign values other than :controller and :action 12 | 13 | # Sample of named route: 14 | # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase 15 | # This route can be invoked with purchase_url(:id => product.id) 16 | 17 | # Sample resource route (maps HTTP verbs to controller actions automatically): 18 | # resources :products 19 | 20 | # Sample resource route with options: 21 | # resources :products do 22 | # member do 23 | # get 'short' 24 | # post 'toggle' 25 | # end 26 | # 27 | # collection do 28 | # get 'sold' 29 | # end 30 | # end 31 | 32 | # Sample resource route with sub-resources: 33 | # resources :products do 34 | # resources :comments, :sales 35 | # resource :seller 36 | # end 37 | 38 | # Sample resource route with more complex sub-resources 39 | # resources :products do 40 | # resources :comments 41 | # resources :sales do 42 | # get 'recent', :on => :collection 43 | # end 44 | # end 45 | 46 | # Sample resource route within a namespace: 47 | # namespace :admin do 48 | # # Directs /admin/products/* to Admin::ProductsController 49 | # # (app/controllers/admin/products_controller.rb) 50 | # resources :products 51 | # end 52 | 53 | # You can have the root of your site routed with "root" 54 | # just remember to delete public/index.html. 55 | # root :to => 'welcome#index' 56 | 57 | # See how all your routes lay out with "rake routes" 58 | 59 | # This is a legacy wild controller route that's not recommended for RESTful applications. 60 | # Note: This route will make all actions in every controller accessible via GET requests. 61 | # match ':controller(/:action(/:id))(.:format)' 62 | end 63 | -------------------------------------------------------------------------------- /spec/dummy/db/development.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotex82/active_admin-awesome_nested_set/7e2d97e819dea162c05f16d70780cb7f37200cef/spec/dummy/db/development.sqlite3 -------------------------------------------------------------------------------- /spec/dummy/db/migrate/20130228120819_devise_create_admin_users.rb: -------------------------------------------------------------------------------- 1 | class DeviseCreateAdminUsers < ActiveRecord::Migration 2 | def migrate(direction) 3 | super 4 | # Create a default user 5 | AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') if direction == :up 6 | end 7 | 8 | def change 9 | create_table(:admin_users) do |t| 10 | ## Database authenticatable 11 | t.string :email, :null => false, :default => "" 12 | t.string :encrypted_password, :null => false, :default => "" 13 | 14 | ## Recoverable 15 | t.string :reset_password_token 16 | t.datetime :reset_password_sent_at 17 | 18 | ## Rememberable 19 | t.datetime :remember_created_at 20 | 21 | ## Trackable 22 | t.integer :sign_in_count, :default => 0 23 | t.datetime :current_sign_in_at 24 | t.datetime :last_sign_in_at 25 | t.string :current_sign_in_ip 26 | t.string :last_sign_in_ip 27 | 28 | ## Confirmable 29 | # t.string :confirmation_token 30 | # t.datetime :confirmed_at 31 | # t.datetime :confirmation_sent_at 32 | # t.string :unconfirmed_email # Only if using reconfirmable 33 | 34 | ## Lockable 35 | # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts 36 | # t.string :unlock_token # Only if unlock strategy is :email or :both 37 | # t.datetime :locked_at 38 | 39 | ## Token authenticatable 40 | # t.string :authentication_token 41 | 42 | 43 | t.timestamps 44 | end 45 | 46 | add_index :admin_users, :email, :unique => true 47 | add_index :admin_users, :reset_password_token, :unique => true 48 | # add_index :admin_users, :confirmation_token, :unique => true 49 | # add_index :admin_users, :unlock_token, :unique => true 50 | # add_index :admin_users, :authentication_token, :unique => true 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /spec/dummy/db/migrate/20130228120821_create_admin_notes.rb: -------------------------------------------------------------------------------- 1 | class CreateAdminNotes < ActiveRecord::Migration 2 | def self.up 3 | create_table :admin_notes do |t| 4 | t.string :resource_id, :null => false 5 | t.string :resource_type, :null => false 6 | t.references :admin_user, :polymorphic => true 7 | t.text :body 8 | t.timestamps 9 | end 10 | add_index :admin_notes, [:resource_type, :resource_id] 11 | add_index :admin_notes, [:admin_user_type, :admin_user_id] 12 | end 13 | 14 | def self.down 15 | drop_table :admin_notes 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/dummy/db/migrate/20130228120822_move_admin_notes_to_comments.rb: -------------------------------------------------------------------------------- 1 | class MoveAdminNotesToComments < ActiveRecord::Migration 2 | def self.up 3 | remove_index :admin_notes, [:admin_user_type, :admin_user_id] 4 | rename_table :admin_notes, :active_admin_comments 5 | rename_column :active_admin_comments, :admin_user_type, :author_type 6 | rename_column :active_admin_comments, :admin_user_id, :author_id 7 | add_column :active_admin_comments, :namespace, :string 8 | add_index :active_admin_comments, [:namespace] 9 | add_index :active_admin_comments, [:author_type, :author_id] 10 | 11 | # Update all the existing comments to the default namespace 12 | say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace." 13 | comments_table_name = ActiveRecord::Migrator.proper_table_name("active_admin_comments") 14 | execute "UPDATE #{comments_table_name} SET namespace='#{ActiveAdmin.application.default_namespace}'" 15 | end 16 | 17 | def self.down 18 | remove_index :active_admin_comments, :column => [:author_type, :author_id] 19 | remove_index :active_admin_comments, :column => [:namespace] 20 | remove_column :active_admin_comments, :namespace 21 | rename_column :active_admin_comments, :author_id, :admin_user_id 22 | rename_column :active_admin_comments, :author_type, :admin_user_type 23 | rename_table :active_admin_comments, :admin_notes 24 | add_index :admin_notes, [:admin_user_type, :admin_user_id] 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/dummy/db/migrate/20130228121407_create_categories.rb: -------------------------------------------------------------------------------- 1 | class CreateCategories < ActiveRecord::Migration 2 | def change 3 | create_table :categories do |t| 4 | t.string :name 5 | 6 | # awesome nested set 7 | t.integer :lft 8 | t.integer :rgt 9 | t.integer :parent_id 10 | t.integer :depth 11 | 12 | t.timestamps 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/dummy/db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended to check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(:version => 20130228121407) do 14 | 15 | create_table "active_admin_comments", :force => true do |t| 16 | t.string "resource_id", :null => false 17 | t.string "resource_type", :null => false 18 | t.integer "author_id" 19 | t.string "author_type" 20 | t.text "body" 21 | t.datetime "created_at", :null => false 22 | t.datetime "updated_at", :null => false 23 | t.string "namespace" 24 | end 25 | 26 | add_index "active_admin_comments", ["author_type", "author_id"], :name => "index_active_admin_comments_on_author_type_and_author_id" 27 | add_index "active_admin_comments", ["namespace"], :name => "index_active_admin_comments_on_namespace" 28 | add_index "active_admin_comments", ["resource_type", "resource_id"], :name => "index_admin_notes_on_resource_type_and_resource_id" 29 | 30 | create_table "admin_users", :force => true do |t| 31 | t.string "email", :default => "", :null => false 32 | t.string "encrypted_password", :default => "", :null => false 33 | t.string "reset_password_token" 34 | t.datetime "reset_password_sent_at" 35 | t.datetime "remember_created_at" 36 | t.integer "sign_in_count", :default => 0 37 | t.datetime "current_sign_in_at" 38 | t.datetime "last_sign_in_at" 39 | t.string "current_sign_in_ip" 40 | t.string "last_sign_in_ip" 41 | t.datetime "created_at", :null => false 42 | t.datetime "updated_at", :null => false 43 | end 44 | 45 | add_index "admin_users", ["email"], :name => "index_admin_users_on_email", :unique => true 46 | add_index "admin_users", ["reset_password_token"], :name => "index_admin_users_on_reset_password_token", :unique => true 47 | 48 | create_table "categories", :force => true do |t| 49 | t.string "name" 50 | t.integer "lft" 51 | t.integer "rgt" 52 | t.integer "parent_id" 53 | t.integer "depth" 54 | t.datetime "created_at", :null => false 55 | t.datetime "updated_at", :null => false 56 | end 57 | 58 | end 59 | -------------------------------------------------------------------------------- /spec/dummy/db/test.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotex82/active_admin-awesome_nested_set/7e2d97e819dea162c05f16d70780cb7f37200cef/spec/dummy/db/test.sqlite3 -------------------------------------------------------------------------------- /spec/dummy/lib/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotex82/active_admin-awesome_nested_set/7e2d97e819dea162c05f16d70780cb7f37200cef/spec/dummy/lib/assets/.gitkeep -------------------------------------------------------------------------------- /spec/dummy/log/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotex82/active_admin-awesome_nested_set/7e2d97e819dea162c05f16d70780cb7f37200cef/spec/dummy/log/.gitkeep -------------------------------------------------------------------------------- /spec/dummy/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The page you were looking for doesn't exist.

23 |

You may have mistyped the address or the page may have moved.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /spec/dummy/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The change you wanted was rejected.

23 |

Maybe you tried to change something you didn't have access to.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /spec/dummy/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

We're sorry, but something went wrong.

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /spec/dummy/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotex82/active_admin-awesome_nested_set/7e2d97e819dea162c05f16d70780cb7f37200cef/spec/dummy/public/favicon.ico -------------------------------------------------------------------------------- /spec/dummy/script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 3 | 4 | APP_PATH = File.expand_path('../../config/application', __FILE__) 5 | require File.expand_path('../../config/boot', __FILE__) 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /spec/dummy/spec: -------------------------------------------------------------------------------- 1 | ../../spec -------------------------------------------------------------------------------- /spec/dummy/test/factories/categories.rb: -------------------------------------------------------------------------------- 1 | # Read about factories at https://github.com/thoughtbot/factory_girl 2 | 3 | FactoryGirl.define do 4 | factory :category do 5 | name "MyString" 6 | lft 1 7 | rgt 1 8 | parent_id 1 9 | "" 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/factories/admin_user_factories.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :admin_user do 3 | sequence(:email) { |i| "example#{i}@example.com" } 4 | password "password" 5 | password_confirmation "password" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/factories/category_factories.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :category do 3 | sequence(:name) { |i| "Category ##{i}" } 4 | 5 | factory :subcategory do 6 | association :parent, :factory => :category 7 | end 8 | end 9 | end 10 | 11 | -------------------------------------------------------------------------------- /spec/features/categories_admin_feature_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | feature 'Category admin' do 4 | include ActiveAdmin::SignInHelper 5 | 6 | def set_locale 7 | I18n.locale = :en 8 | end 9 | 10 | def set_admin_area_path 11 | @admin_area_path = "/admin" 12 | end 13 | 14 | def set_resource_path 15 | @resource_path = "categories" 16 | end 17 | 18 | def set_resource_class 19 | @resource_class = Category 20 | end 21 | 22 | def set_resource_factory_name 23 | @resource_factory_name = @resource_class.to_s.underscore.gsub('/', '_').to_sym 24 | end 25 | 26 | def set_index_check_column 27 | @index_check_column = :name 28 | end 29 | 30 | def prepare_for_new 31 | end 32 | 33 | def fill_new_form 34 | fill_in 'category[name]', :with => 'An example category' 35 | end 36 | 37 | def fill_edit_form 38 | fill_in 'category[name]', :with => 'An updated example category' 39 | end 40 | 41 | background do 42 | admin_user = FactoryGirl.create(:admin_user) 43 | sign_in_with(admin_user.email, admin_user.password) 44 | 45 | set_locale 46 | set_admin_area_path 47 | set_resource_class 48 | set_resource_path 49 | set_resource_factory_name 50 | end 51 | 52 | describe 'new' do 53 | background do 54 | @resource_count = @resource_class.count 55 | prepare_for_new 56 | visit "#{@admin_area_path}/#{@resource_path}/new" 57 | end 58 | 59 | scenario 'should be visitable' do 60 | page.current_path.should eq("#{@admin_area_path}/#{@resource_path}/new") 61 | end # scenario 62 | 63 | scenario 'should have the status code 200' do 64 | page.status_code.should eq(200) 65 | end # scenario 66 | 67 | describe 'when filling the form correctly' do 68 | background do 69 | fill_new_form 70 | find(:xpath, '//input[@type="submit"]').click 71 | end 72 | 73 | scenario 'should have created a record' do 74 | @resource_class.count.should eq(@resource_count + 1) 75 | end # scenario 76 | 77 | scenario 'should have the status code 200' do 78 | page.status_code.should eq(200) 79 | end # scenario 80 | end # describe 'when filling the form correctly' 81 | end # describe 'new' 82 | 83 | describe 'show' do 84 | background do 85 | @resource = FactoryGirl.create(@resource_factory_name) 86 | visit "#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}" 87 | end 88 | 89 | scenario 'should have the status code 200' do 90 | page.status_code.should eq(200) 91 | end # scenario 92 | end # describe 'show' 93 | 94 | describe 'edit' do 95 | background do 96 | @resource = FactoryGirl.create(@resource_factory_name) 97 | visit "#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}/edit" 98 | end 99 | 100 | scenario 'should be visitable' do 101 | page.current_path.should eq("#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}/edit") 102 | end # scenario 103 | 104 | scenario 'should have the status code 200' do 105 | page.status_code.should eq(200) 106 | end # scenario 107 | 108 | describe 'when filling the form correctly' do 109 | background do 110 | @resource_count = @resource_class.count 111 | fill_edit_form 112 | find(:xpath, '//input[@type="submit"]').click 113 | @resource.reload 114 | end 115 | 116 | scenario 'should not have created a record' do 117 | @resource_class.count.should eq(@resource_count) 118 | end # scenario 119 | 120 | scenario 'should have the status code 200' do 121 | page.status_code.should eq(200) 122 | end # scenario 123 | 124 | scenario 'should redirect to the resource show page' do 125 | page.current_path.should eq("#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}") 126 | end # scenario 127 | end # describe 'when filling the form correctly' 128 | 129 | end # describe 'edit' 130 | 131 | describe 'delete' do 132 | background do 133 | @resource = FactoryGirl.create(@resource_factory_name) 134 | @resource_count = @resource_class.count 135 | visit "#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}" 136 | find(:xpath, "//a[@href='#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}' and @data-method='delete']").click 137 | end 138 | 139 | scenario 'should delete the resource' do 140 | @resource_class.count.should eq(@resource_count - 1) 141 | end # scenario 142 | 143 | scenario 'should redirect to the resource index page' do 144 | page.current_path.should eq("#{@admin_area_path}/#{@resource_path}") 145 | end # scenario 146 | end # describe 'delete' 147 | 148 | describe 'index' do 149 | background do 150 | set_index_check_column 151 | @resources = FactoryGirl.create_list(@resource_factory_name, 3) 152 | visit "#{@admin_area_path}/#{@resource_path}" 153 | end 154 | 155 | scenario 'should be visitable' do 156 | page.current_path.should eq("#{@admin_area_path}/#{@resource_path}") 157 | end # scenario 158 | 159 | scenario 'should have the status code 200' do 160 | page.status_code.should eq(200) 161 | end # scenario 162 | 163 | scenario "should show the resources" do 164 | @resources.each do |resource| 165 | page.body.should include(resource.send(@index_check_column.to_sym)) 166 | end 167 | end # scenario 168 | end # describe 'index' 169 | end # feature 170 | 171 | -------------------------------------------------------------------------------- /spec/features/sortable_tree_feature_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | feature 'Sortable tree' do 4 | include ActiveAdmin::SignInHelper 5 | 6 | background do 7 | I18n.locale = :en 8 | admin_user = FactoryGirl.create(:admin_user) 9 | sign_in_with(admin_user.email, admin_user.password) 10 | end # before 11 | 12 | describe 'Sorting parent items on the admin index page' do 13 | before do 14 | @first_parent = FactoryGirl.create(:category, :parent => nil) 15 | @second_parent = FactoryGirl.create(:category, :parent => nil) 16 | visit '/admin/categories' 17 | end # before 18 | 19 | describe 'Move first item to the second place' do 20 | before do 21 | find(:xpath, "//a[@href='/admin/categories/#{@first_parent.to_param}/move_down']").click 22 | end # before 23 | 24 | scenario 'should have the status code 200' do 25 | page.status_code.should eq(200) 26 | end # scenario 27 | 28 | scenario 'should redirect to the index page' do 29 | page.current_path.should eq("/admin/categories") 30 | end # scenario 31 | 32 | scenario 'should move the item to the second place' do 33 | page.find(:xpath, "(//td[@class='name'])[1]").text.should eq(@second_parent.name) 34 | page.find(:xpath, "(//td[@class='name'])[2]").text.should eq(@first_parent.name) 35 | end # scenario 36 | end 37 | end # describe 'Sorting parent items on the admin index page' 38 | 39 | describe 'Item indentation' do 40 | before do 41 | @child = FactoryGirl.create(:subcategory) 42 | @parent = @child.parent 43 | visit '/admin/categories' 44 | end # before 45 | 46 | it 'should not indent the parent item' do 47 | page.should have_css("span[style='padding-left:0px']", :text => "• #{@parent.name}") 48 | end # it 49 | 50 | it 'should indent the child item' do 51 | end # it 52 | end # describe 'Item indentation' 53 | end # feature 'Sortable tree' 54 | -------------------------------------------------------------------------------- /spec/models/category_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Category do 4 | context 'validations' do 5 | should { validate_presence_of(:name) } 6 | end # context 'validations' 7 | end 8 | -------------------------------------------------------------------------------- /spec/models/generic_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe "ActiveRecord::Base models" do 4 | ActiveRecord::Base.descendants.map(&:to_s).reject() { |m| %w(ActiveAdmin::Comment AdminUser).include?(m) }.each do |model_name| 5 | model = model_name.constantize 6 | describe model do 7 | it "should be an ActiveRecord::Base" do 8 | ActiveRecord::Base.descendants.should include(model) 9 | end 10 | 11 | it "should be instanciable" do 12 | instance = model.new 13 | instance.should be_a model 14 | end 15 | 16 | it "should be valid with correct attribute values" do 17 | instance = FactoryGirl.create(model.to_s.tableize.singularize.underscore.gsub( '/', '_')) 18 | instance.should be_valid 19 | end 20 | 21 | it "should not be valid with empty attributes" do 22 | instance = model.new 23 | instance.should_not be_valid 24 | end 25 | 26 | it "should save with valid attributes" do 27 | instance = FactoryGirl.create(model.to_s.tableize.singularize.underscore.gsub( '/', '_')) 28 | instance.save.should be_true 29 | instance.should be_persisted 30 | end 31 | end 32 | end 33 | end 34 | 35 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | ENV["RAILS_ENV"] ||= 'test' 3 | require File.expand_path("../dummy/config/environment", __FILE__) 4 | require 'rspec/rails' 5 | require 'rspec/autorun' 6 | 7 | # Requires supporting ruby files with custom matchers and macros, etc, 8 | # in spec/support/ and its subdirectories. 9 | Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} 10 | 11 | RSpec.configure do |config| 12 | # ## Mock Framework 13 | # 14 | # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: 15 | # 16 | # config.mock_with :mocha 17 | # config.mock_with :flexmock 18 | # config.mock_with :rr 19 | 20 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 21 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 22 | 23 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 24 | # examples within a transaction, remove the following line or assign false 25 | # instead of true. 26 | config.use_transactional_fixtures = true 27 | 28 | # If true, the base class of anonymous controllers will be inferred 29 | # automatically. This will be the default behavior in future versions of 30 | # rspec-rails. 31 | config.infer_base_class_for_anonymous_controllers = false 32 | 33 | # Run specs in random order to surface order dependencies. If you find an 34 | # order dependency and want to debug it, you can fix the order by providing 35 | # the seed, which is printed after each run. 36 | # --seed 1234 37 | config.order = "random" 38 | end 39 | 40 | -------------------------------------------------------------------------------- /spec/support/active_admin/sign_in_helper.rb: -------------------------------------------------------------------------------- 1 | module ActiveAdmin::SignInHelper 2 | def sign_in(admin_user) 3 | post admin_user_session_path, { 4 | :admin_user => { 5 | :email => admin_user.email, 6 | :password => admin_user.password 7 | } 8 | } 9 | end 10 | 11 | def sign_in_with(email, password) 12 | visit '/admin/login' 13 | fill_in 'admin_user[email]', :with => email 14 | fill_in 'admin_user[password]', :with => password 15 | find(:xpath, '//input[@type="submit"]').click 16 | end 17 | end 18 | 19 | -------------------------------------------------------------------------------- /spec/support/factory_girl.rb: -------------------------------------------------------------------------------- 1 | require 'factory_girl' 2 | FactoryGirl.find_definitions 3 | 4 | --------------------------------------------------------------------------------