Permalink
Browse files

Split off wiki page gems. Also fix testing code.

  • Loading branch information...
1 parent 039f20b commit 995c0b975bd45939abb030e19efdb15a44ce365f @jamesu committed Oct 4, 2011
Showing with 36 additions and 4,173 deletions.
  1. +3 −0 Gemfile
  2. +13 −0 Gemfile.lock
  3. +6 −11 app/controllers/wiki_pages_controller.rb
  4. +11 −11 app/models/wiki_page.rb
  5. +2 −2 app/models/wiki_page_user.rb
  6. +1 −0 test/test_helper.rb
  7. +0 −82 vendor/plugins/acts_as_versioned/CHANGELOG
  8. +0 −20 vendor/plugins/acts_as_versioned/MIT-LICENSE
  9. +0 −28 vendor/plugins/acts_as_versioned/README
  10. +0 −41 vendor/plugins/acts_as_versioned/RUNNING_UNIT_TESTS
  11. +0 −180 vendor/plugins/acts_as_versioned/Rakefile
  12. +0 −4 vendor/plugins/acts_as_versioned/VERSION.yml
  13. +0 −29 vendor/plugins/acts_as_versioned/acts_as_versioned.gemspec
  14. +0 −1 vendor/plugins/acts_as_versioned/init.rb
  15. +0 −486 vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb
  16. +0 −48 vendor/plugins/acts_as_versioned/test/abstract_unit.rb
  17. +0 −18 vendor/plugins/acts_as_versioned/test/database.yml
  18. +0 −6 vendor/plugins/acts_as_versioned/test/fixtures/authors.yml
  19. +0 −3 vendor/plugins/acts_as_versioned/test/fixtures/landmark.rb
  20. +0 −7 vendor/plugins/acts_as_versioned/test/fixtures/landmark_versions.yml
  21. +0 −7 vendor/plugins/acts_as_versioned/test/fixtures/landmarks.yml
  22. +0 −10 vendor/plugins/acts_as_versioned/test/fixtures/locked_pages.yml
  23. +0 −27 vendor/plugins/acts_as_versioned/test/fixtures/locked_pages_revisions.yml
  24. +0 −15 vendor/plugins/acts_as_versioned/test/fixtures/migrations/1_add_versioned_tables.rb
  25. +0 −43 vendor/plugins/acts_as_versioned/test/fixtures/page.rb
  26. +0 −16 vendor/plugins/acts_as_versioned/test/fixtures/page_versions.yml
  27. +0 −8 vendor/plugins/acts_as_versioned/test/fixtures/pages.yml
  28. +0 −6 vendor/plugins/acts_as_versioned/test/fixtures/widget.rb
  29. +0 −46 vendor/plugins/acts_as_versioned/test/migration_test.rb
  30. +0 −82 vendor/plugins/acts_as_versioned/test/schema.rb
  31. +0 −370 vendor/plugins/acts_as_versioned/test/versioned_test.rb
  32. +0 −172 vendor/plugins/friendly_id/History.txt
  33. +0 −19 vendor/plugins/friendly_id/MIT-LICENSE
  34. +0 −42 vendor/plugins/friendly_id/Manifest.txt
  35. +0 −384 vendor/plugins/friendly_id/README.rdoc
  36. +0 −46 vendor/plugins/friendly_id/Rakefile
  37. +0 −2 vendor/plugins/friendly_id/config/website.yml
  38. +0 −3 vendor/plugins/friendly_id/extras/README
  39. +0 −26 vendor/plugins/friendly_id/extras/template-gem.rb
  40. +0 −28 vendor/plugins/friendly_id/extras/template-plugin.rb
  41. +0 −28 vendor/plugins/friendly_id/generators/friendly_id/friendly_id_generator.rb
  42. +0 −18 vendor/plugins/friendly_id/generators/friendly_id/templates/create_slugs.rb
  43. +0 −12 vendor/plugins/friendly_id/generators/friendly_id_20_upgrade/friendly_id_20_upgrade_generator.rb
  44. +0 −19 vendor/plugins/friendly_id/generators/friendly_id_20_upgrade/templates/upgrade_friendly_id_to_20.rb
  45. +0 −1 vendor/plugins/friendly_id/init.rb
  46. +0 −75 vendor/plugins/friendly_id/lib/friendly_id.rb
  47. +0 −12 vendor/plugins/friendly_id/lib/friendly_id/helpers.rb
  48. +0 −33 vendor/plugins/friendly_id/lib/friendly_id/non_sluggable_class_methods.rb
  49. +0 −45 vendor/plugins/friendly_id/lib/friendly_id/non_sluggable_instance_methods.rb
  50. +0 −98 vendor/plugins/friendly_id/lib/friendly_id/slug.rb
  51. +0 −110 vendor/plugins/friendly_id/lib/friendly_id/sluggable_class_methods.rb
  52. +0 −145 vendor/plugins/friendly_id/lib/friendly_id/sluggable_instance_methods.rb
  53. +0 −56 vendor/plugins/friendly_id/lib/friendly_id/tasks.rb
  54. +0 −8 vendor/plugins/friendly_id/lib/friendly_id/version.rb
  55. +0 −25 vendor/plugins/friendly_id/lib/tasks/friendly_id.rake
  56. +0 −1 vendor/plugins/friendly_id/lib/tasks/friendly_id.rb
  57. +0 −112 vendor/plugins/friendly_id/test/cached_slug_test.rb
  58. +0 −94 vendor/plugins/friendly_id/test/contest.rb
  59. +0 −38 vendor/plugins/friendly_id/test/custom_slug_normalizer_test.rb
  60. +0 −2 vendor/plugins/friendly_id/test/models/book.rb
  61. +0 −4 vendor/plugins/friendly_id/test/models/city.rb
  62. +0 −4 vendor/plugins/friendly_id/test/models/country.rb
  63. +0 −3 vendor/plugins/friendly_id/test/models/district.rb
  64. +0 −3 vendor/plugins/friendly_id/test/models/event.rb
  65. +0 −4 vendor/plugins/friendly_id/test/models/legacy_thing.rb
  66. +0 −3 vendor/plugins/friendly_id/test/models/novel.rb
  67. +0 −6 vendor/plugins/friendly_id/test/models/person.rb
  68. +0 −6 vendor/plugins/friendly_id/test/models/post.rb
  69. +0 −6 vendor/plugins/friendly_id/test/models/thing.rb
  70. +0 −3 vendor/plugins/friendly_id/test/models/user.rb
  71. +0 −101 vendor/plugins/friendly_id/test/non_slugged_test.rb
  72. +0 −70 vendor/plugins/friendly_id/test/schema.rb
  73. +0 −56 vendor/plugins/friendly_id/test/scoped_model_test.rb
  74. +0 −106 vendor/plugins/friendly_id/test/slug_test.rb
  75. +0 −342 vendor/plugins/friendly_id/test/slugged_model_test.rb
  76. +0 −51 vendor/plugins/friendly_id/test/sti_test.rb
  77. +0 −106 vendor/plugins/friendly_id/test/tasks_test.rb
  78. +0 −38 vendor/plugins/friendly_id/test/test_helper.rb
View
@@ -11,7 +11,10 @@ gem 'dynamic_form'
gem 'will_paginate', '~> 3.0'
gem 'RedCloth'
gem 'icalendar'
+gem 'faker'
gem 'factory_girl'
+gem 'friendly_id', '~> 4.0.0.beta8'
+gem 'acts_as_versioned', :git => "git://github.com/firien/acts_as_versioned.git"
gem 'jquery-rails', '>= 1.0.12'
#group :test, :development do
View
@@ -1,4 +1,11 @@
GIT
+ remote: git://github.com/firien/acts_as_versioned.git
+ revision: f7eaf9b32c030fe46585bc7984de622e7a02bd63
+ specs:
+ acts_as_versioned (0.6.0)
+ activerecord (>= 3.0.0)
+
+GIT
remote: git://github.com/teambox/choices.git
revision: 93d0cfb4e5fd4ae03b421b379a69ee00721f337b
specs:
@@ -50,6 +57,9 @@ GEM
execjs (1.2.0)
multi_json (~> 1.0)
factory_girl (1.3.3)
+ faker (0.9.5)
+ i18n (~> 0.4)
+ friendly_id (4.0.0.beta12)
haml (3.1.2)
hashie (1.0.0)
hike (1.1.0)
@@ -125,10 +135,13 @@ PLATFORMS
DEPENDENCIES
RedCloth
+ acts_as_versioned!
cancan
choices!
dynamic_form
factory_girl
+ faker
+ friendly_id (~> 4.0.0.beta8)
haml
icalendar
jquery-rails (>= 1.0.12)
@@ -20,7 +20,6 @@ class WikiPagesController < ApplicationController
layout 'project_website'
before_filter :process_session
- before_filter :set_created_by, :only => [:create, :update]
before_filter :find_sidebar_page, :only => [:index, :show]
after_filter :user_track, :only => [:index, :show]
@@ -56,10 +55,10 @@ def show
end
def create
- @wiki_page = wiki_pages.new(params[:wiki_page])
+ @wiki_page = wiki_pages.new(params[:wiki_page].merge(:created_by => @logged_user))
if @wiki_page.save
- flash[:message] = I18n.t :success_creating_wiki_page, :scope => :wiki_engine
+ flash[:message] = I18n.t 'wiki_engine.success_creating_wiki_page'
redirect_to @wiki_page.main ? wiki_pages_path : wiki_page_path(:id => @wiki_page)
else
render :action => 'new'
@@ -70,8 +69,8 @@ def edit
end
def update
- if @wiki_page.update_attributes(params[:wiki_page])
- flash[:message] = I18n.t :success_updating_wiki_page, :scope => :wiki_engine
+ if @wiki_page.update_attributes(params[:wiki_page].merge(:created_by => @logged_user))
+ flash[:message] = I18n.t 'wiki_engine.success_updating_wiki_page'
redirect_to @wiki_page.main ? wiki_pages_path : wiki_page_path(:id => @wiki_page)
else
render :action => 'edit'
@@ -81,7 +80,7 @@ def update
def destroy
@wiki_page.destroy
- flash[:message] = I18n.t :success_deleting_wiki_page, :scope => :wiki_engine
+ flash[:message] = I18n.t 'wiki_engine.success_deleting_wiki_page'
redirect_to wiki_pages_path
end
@@ -106,7 +105,7 @@ def find_wiki_page
# Find main wiki page. This is by default used only for index action.
def find_main_wiki_page
- @wiki_page = wiki_pages.main.first
+ @wiki_page = wiki_pages.main(@active_project).first
end
# Find all wiki pages. This is by default used only for list action.
@@ -132,10 +131,6 @@ def check_delete_permissions
authorize! :delete, @wiki_page
end
- def set_created_by
- params[:wiki_page][:created_by] = @logged_user
- end
-
def wiki_pages
@active_project.wiki_pages
end
View
@@ -1,19 +1,18 @@
class WikiPage < ActiveRecord::Base
+ extend FriendlyId
include Rails.application.routes.url_helpers
include WikiPageUser
before_save :set_main_page
acts_as_versioned :extend => WikiPageUser
- has_friendly_id :title, :use_slug => true, :strip_diacritics => true
+ friendly_id :title, :use => :slugged, :slug_column => :title
validates_presence_of :title
def title_from_id=(id)
self.title = id.to_s.underscore.humanize if id
end
belongs_to :project
- # self.friendly_id_options[:scope] = :project
- self.friendly_id_options[:scope] = :scope_value
self.non_versioned_columns << :project_id
scope :main, lambda{ |project| where(:main => true, :project_id => project.id) }
@@ -22,36 +21,37 @@ def title_from_id=(id)
before_destroy :process_destroy
def scope_value
- self.project.id.to_s
+ project.id.to_s
end
def process_create
- Activity.new_log(self, self.created_by, :add)
+ Activity.new_log(self, created_by, :add)
end
def process_update_params
- Activity.new_log(self, self.created_by, :edit)
+ Activity.new_log(self, created_by, :edit)
end
def process_destroy
- Activity.new_log(self, self.created_by, :delete)
+ Activity.new_log(self, created_by, :delete)
end
def object_name
- self.title
+ title
end
def object_url(host = nil)
- url_for :only_path => host.nil?, :host => host, :controller => 'wiki_pages', :action => 'show', :id => self, :active_project => self.project_id
+ url_for :only_path => host.nil?, :host => host, :controller => 'wiki_pages', :action => 'show', :id => self, :active_project => project_id
end
protected
def main_page
- @main_page ||= self.class.main(project).first
+ @main_page ||= WikiPage.main(project).first
end
def set_main_page
- self.main_page.update_attribute :main, false if self.main && !self.main_was && self.main_page
+ main_page.update_attribute :main, false if main && !main_was && main_page
+ true
end
end
@@ -4,10 +4,10 @@ def self.included(base)
end
def user
- self.created_by
+ created_by
end
def user_name
- user.display_name if self.user
+ user.display_name if user
end
end
View
@@ -1,6 +1,7 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
+require 'factories'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
@@ -1,82 +0,0 @@
-*GIT* (version numbers are overrated)
-
-* (16 Jun 2008) Backwards Compatibility is overrated (big updates for rails 2.1)
-
- * Use ActiveRecord 2.1's dirty attribute checking instead [Asa Calow]
- * Remove last traces of #non_versioned_fields
- * Remove AR::Base.find_version and AR::Base.find_versions, rely on AR association proxies and named_scope
- * Remove #versions_count, rely on AR association counter caching.
- * Remove #versioned_attributes, basically the same as AR::Base.versioned_columns
-
-* (5 Oct 2006) Allow customization of #versions association options [Dan Peterson]
-
-*0.5.1*
-
-* (8 Aug 2006) Versioned models now belong to the unversioned model. @article_version.article.class => Article [Aslak Hellesoy]
-
-*0.5* # do versions even matter for plugins?
-
-* (21 Apr 2006) Added without_locking and without_revision methods.
-
- Foo.without_revision do
- @foo.update_attributes ...
- end
-
-*0.4*
-
-* (28 March 2006) Rename non_versioned_fields to non_versioned_columns (old one is kept for compatibility).
-* (28 March 2006) Made explicit documentation note that string column names are required for non_versioned_columns.
-
-*0.3.1*
-
-* (7 Jan 2006) explicitly set :foreign_key option for the versioned model's belongs_to assocation for STI [Caged]
-* (7 Jan 2006) added tests to prove has_many :through joins work
-
-*0.3*
-
-* (2 Jan 2006) added ability to share a mixin with versioned class
-* (2 Jan 2006) changed the dynamic version model to MyModel::Version
-
-*0.2.4*
-
-* (27 Nov 2005) added note about possible destructive behavior of if_changed? [Michael Schuerig]
-
-*0.2.3*
-
-* (12 Nov 2005) fixed bug with old behavior of #blank? [Michael Schuerig]
-* (12 Nov 2005) updated tests to use ActiveRecord Schema
-
-*0.2.2*
-
-* (3 Nov 2005) added documentation note to #acts_as_versioned [Martin Jul]
-
-*0.2.1*
-
-* (6 Oct 2005) renamed dirty? to changed? to keep it uniform. it was aliased to keep it backwards compatible.
-
-*0.2*
-
-* (6 Oct 2005) added find_versions and find_version class methods.
-
-* (6 Oct 2005) removed transaction from create_versioned_table().
- this way you can specify your own transaction around a group of operations.
-
-* (30 Sep 2005) fixed bug where find_versions() would order by 'version' twice. (found by Joe Clark)
-
-* (26 Sep 2005) added :sequence_name option to acts_as_versioned to set the sequence name on the versioned model
-
-*0.1.3* (18 Sep 2005)
-
-* First RubyForge release
-
-*0.1.2*
-
-* check if module is already included when acts_as_versioned is called
-
-*0.1.1*
-
-* Adding tests and rdocs
-
-*0.1*
-
-* Initial transfer from Rails ticket: http://dev.rubyonrails.com/ticket/1974
@@ -1,20 +0,0 @@
-Copyright (c) 2005 Rick Olson
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,28 +0,0 @@
-= acts_as_versioned
-
-This library adds simple versioning to an ActiveRecord module. ActiveRecord is required.
-
-== Resources
-
-Install
-
-* gem install acts_as_versioned
-
-Rubyforge project
-
-* http://rubyforge.org/projects/ar-versioned
-
-RDocs
-
-* http://ar-versioned.rubyforge.org
-
-Subversion
-
-* http://techno-weenie.net/svn/projects/acts_as_versioned
-
-Collaboa
-
-* http://collaboa.techno-weenie.net/repository/browse/acts_as_versioned
-
-Special thanks to Dreamer on ##rubyonrails for help in early testing. His ServerSideWiki (http://serversidewiki.com)
-was the first project to use acts_as_versioned <em>in the wild</em>.
@@ -1,41 +0,0 @@
-== Creating the test database
-
-The default name for the test databases is "activerecord_versioned". If you
-want to use another database name then be sure to update the connection
-adapter setups you want to test with in test/connections/<your database>/connection.rb.
-When you have the database online, you can import the fixture tables with
-the test/fixtures/db_definitions/*.sql files.
-
-Make sure that you create database objects with the same user that you specified in i
-connection.rb otherwise (on Postgres, at least) tests for default values will fail.
-
-== Running with Rake
-
-The easiest way to run the unit tests is through Rake. The default task runs
-the entire test suite for all the adapters. You can also run the suite on just
-one adapter by using the tasks test_mysql_ruby, test_ruby_mysql, test_sqlite,
-or test_postresql. For more information, checkout the full array of rake tasks with "rake -T"
-
-Rake can be found at http://rake.rubyforge.org
-
-== Running by hand
-
-Unit tests are located in test directory. If you only want to run a single test suite,
-or don't want to bother with Rake, you can do so with something like:
-
- cd test; ruby -I "connections/native_mysql" base_test.rb
-
-That'll run the base suite using the MySQL-Ruby adapter. Change the adapter
-and test suite name as needed.
-
-== Faster tests
-
-If you are using a database that supports transactions, you can set the
-"AR_TX_FIXTURES" environment variable to "yes" to use transactional fixtures.
-This gives a very large speed boost. With rake:
-
- rake AR_TX_FIXTURES=yes
-
-Or, by hand:
-
- AR_TX_FIXTURES=yes ruby -I connections/native_sqlite3 base_test.rb
Oops, something went wrong.

0 comments on commit 995c0b9

Please sign in to comment.