sogilis-moxie_forum 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. data/README.rdoc +47 -0
  2. data/app/controllers/moxie/admin/forums_controller.rb +71 -0
  3. data/app/controllers/moxie/admin_controller.rb +10 -0
  4. data/app/controllers/moxie/forums_controller.rb +29 -0
  5. data/app/controllers/moxie/posts_controller.rb +52 -0
  6. data/app/controllers/moxie/topics_controller.rb +62 -0
  7. data/app/helpers/moxie/application_helper.rb +3 -0
  8. data/app/helpers/moxie/forums_helper.rb +5 -0
  9. data/app/models/moxie/forum.rb +16 -0
  10. data/app/models/moxie/post.rb +34 -0
  11. data/app/models/moxie/topic.rb +39 -0
  12. data/app/views/layouts/forums.html.erb +14 -0
  13. data/app/views/moxie/admin/forums/_form.html.erb +28 -0
  14. data/app/views/moxie/admin/forums/edit.html.erb +6 -0
  15. data/app/views/moxie/admin/forums/index.html.erb +28 -0
  16. data/app/views/moxie/admin/forums/new.html.erb +5 -0
  17. data/app/views/moxie/admin/forums/show.html.erb +20 -0
  18. data/app/views/moxie/admin/index.html.erb +3 -0
  19. data/app/views/moxie/forums/authorization_error.html.erb +4 -0
  20. data/app/views/moxie/forums/index.html.erb +20 -0
  21. data/app/views/moxie/forums/show.html.erb +38 -0
  22. data/app/views/moxie/posts/_form.html.erb +51 -0
  23. data/app/views/moxie/posts/_post.html.erb +23 -0
  24. data/app/views/moxie/topics/_form.html.erb +50 -0
  25. data/app/views/moxie/topics/new.html.erb +1 -0
  26. data/app/views/moxie/topics/show.html.erb +12 -0
  27. data/config/routes.rb +26 -0
  28. data/lib/application_helper.rb +15 -0
  29. data/lib/moxie_forum/acts_as_moxie_user/base.rb +57 -0
  30. data/lib/moxie_forum/engine.rb +52 -0
  31. data/lib/moxie_forum.rb +4 -0
  32. data/lib/rails/generators/moxie_forum/moxie_forum_generator.rb +130 -0
  33. data/lib/rails/generators/moxie_forum/templates/config.yml +5 -0
  34. data/lib/rails/generators/moxie_forum/templates/initializer.rb +14 -0
  35. data/lib/rails/generators/moxie_forum/templates/migration.rb +20 -0
  36. data/lib/rails/generators/moxie_forum/templates/schema.rb +43 -0
  37. data/lib/rails/railties/tasks.rake +8 -0
  38. data/lib/tasks/tasks.rb +9 -0
  39. data/public/images/gradient_grey.png +0 -0
  40. data/public/stylesheets/moxie_forum.css +223 -0
  41. data/test/generators/moxie_forum_generator_test.rb +10 -0
  42. data/test/test_helper.rb +77 -0
  43. data/test/unit/forum_test.rb +75 -0
  44. metadata +108 -0
@@ -0,0 +1,10 @@
1
+ # require 'test_helper'
2
+ # require 'generators/moxie_forum/moxie_forum_generator'
3
+ #
4
+ # class MoxieForumGeneratorTest < Test::Unit::TestCase
5
+ #
6
+ # def test_install
7
+ # assert true
8
+ # end
9
+ #
10
+ # end
@@ -0,0 +1,77 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'yaml'
6
+ require 'active_record'
7
+ require 'mysql'
8
+
9
+ require 'app/models/moxie/forum.rb'
10
+ require 'app/models/moxie/topic.rb'
11
+ require 'app/models/moxie/post.rb'
12
+
13
+ # class Test::Unit::TestCase
14
+ # class ActiveSupport::TestCase
15
+ # # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
16
+ # #
17
+ # # Note: You'll currently still have to declare fixtures explicitly in integration tests
18
+ # # -- they do not yet inherit this setting
19
+ # fixtures :all
20
+ #
21
+ # # Add more helper methods to be used by all tests here...
22
+ # end
23
+
24
+ def moxie_forums( fixture_name )
25
+ id = @@fixtures['moxie_forum'][ fixture_name.to_s ][ 'id' ]
26
+ Moxie::Forum.find( id )
27
+ end
28
+
29
+ def moxie_topics( fixture_name )
30
+ id = @@fixtures['moxie_topic'][ fixture_name.to_s ][ 'id' ]
31
+ Moxie::Topic.find( id )
32
+ end
33
+
34
+ def moxie_posts( fixture_name )
35
+ id = @@fixtures['moxie_post'][ fixture_name.to_s ][ 'id' ]
36
+ Moxie::Post.find( id )
37
+ end
38
+
39
+ def load_schema
40
+ config = YAML::load( IO.read( File.dirname(__FILE__) + '/database.yml') )
41
+
42
+ ActiveRecord::Base.establish_connection( config['mysql'] )
43
+ ActiveRecord::Base.connection()
44
+
45
+ load(File.dirname(__FILE__) + "/../" +
46
+ "lib/rails/generators/moxie_forum/templates/schema.rb")
47
+
48
+ @@fixtures = {}
49
+
50
+ load_fixture( 'moxie_forum' )
51
+ load_fixture( 'moxie_topic' )
52
+ load_fixture( 'moxie_post' )
53
+ end
54
+
55
+ def load_fixture( table )
56
+ @@fixtures[ table ] = {}
57
+ fixture = YAML::load( IO.read( File.dirname(__FILE__) + "/fixtures/#{table}.yml") )
58
+ @@fixtures[ table ] = fixture
59
+
60
+ klass = class_eval table.titleize.gsub(/ /, '::')
61
+
62
+ fixture.each do |record_name, record|
63
+ record.each do |column, value|
64
+ if ( match = column.match(/(.*)_id/) )
65
+ fixture_reference = "moxie_" + match[1].pluralize
66
+ if value.is_a? Symbol
67
+ r = class_eval "#{fixture_reference}( '#{value}' )"
68
+ record[ column ] = r.id
69
+ end
70
+ end
71
+ end
72
+
73
+ r = klass.create( record )
74
+ @@fixtures[ table ][ record_name ][ 'id' ] = r.id
75
+ end
76
+
77
+ end
@@ -0,0 +1,75 @@
1
+ require 'test_helper'
2
+
3
+ class ForumTest < Test::Unit::TestCase
4
+ load_schema
5
+
6
+ def test_models_are_linked_up
7
+ assert_equal moxie_forums(:announcements).title, "Administrative Announcements",
8
+ "Fixtures were not loaded"
9
+ assert_equal moxie_forums(:announcements).topics.length, 2
10
+ assert moxie_forums(:announcements).topics.include? moxie_topics(:welcome)
11
+ assert_equal moxie_topics(:welcome).forum, moxie_forums(:announcements)
12
+ assert moxie_topics(:welcome).posts.include? moxie_posts(:welcome_msg)
13
+ assert moxie_posts(:welcome_msg).topic, moxie_topics(:welcome)
14
+ end
15
+
16
+ def test_forums_track_topic_count
17
+ start_count = moxie_forums(:announcements).topics.length
18
+ assert_equal moxie_forums(:announcements).topic_count, start_count
19
+
20
+ t = Moxie::Topic.create( :forum_id => moxie_forums(:announcements).id,
21
+ :author_id => 0,
22
+ :title => "Important News" )
23
+
24
+ assert moxie_forums(:announcements).topics.include? t
25
+ assert_equal moxie_forums(:announcements).topics.length, start_count + 1
26
+ t.destroy
27
+ assert_equal moxie_forums(:announcements).topics.length, start_count
28
+ end
29
+
30
+ def test_topics_track_post_count
31
+ start_count = moxie_topics(:welcome).posts.length
32
+ assert_equal moxie_topics(:welcome).post_count, start_count
33
+
34
+ p = Moxie::Post.create( :topic_id => moxie_topics(:welcome).id,
35
+ :author_id => 0,
36
+ :body => "Don't forget to introduce yourself." )
37
+
38
+ assert moxie_topics(:welcome).posts.include? p
39
+ assert_equal moxie_topics(:welcome).posts.length, start_count + 1
40
+ p.destroy
41
+ assert_equal moxie_topics(:welcome).posts.length, start_count
42
+ end
43
+
44
+ def test_topics_and_posts_removed_upon_forum_delete
45
+ f = Moxie::Forum.create( :title => "Dummy forum" )
46
+ t1 = Moxie::Topic.create( :forum_id => f.id,
47
+ :author_id => 0,
48
+ :title => "Dummy topic 1" )
49
+ t2 = Moxie::Topic.create( :forum_id => f.id,
50
+ :author_id => 0,
51
+ :title => "Dummy topic 2" )
52
+ p1 = Moxie::Post.create( :topic_id => t1.id,
53
+ :author_id => 0,
54
+ :body => "Dummy post 1.1" )
55
+ p2 = Moxie::Post.create( :topic_id => t1.id,
56
+ :author_id => 0,
57
+ :body => "Dummy post 1.2" )
58
+
59
+ assert f.topics.include? t1
60
+ assert t1.posts.include? p1
61
+ assert ! Moxie::Forum.where( :id => f.id ).empty?
62
+ assert ! Moxie::Topic.where( :id => t1.id ).empty?
63
+ assert ! Moxie::Post.where( :id => p1.id ).empty?
64
+
65
+ f.destroy
66
+
67
+ assert Moxie::Forum.where( :id => f.id ).empty?
68
+ assert Moxie::Topic.where( :id => t1.id ).empty?
69
+ assert Moxie::Topic.where( :id => t2.id ).empty?
70
+ assert Moxie::Post.where( :id => p1.id ).empty?
71
+ assert Moxie::Post.where( :id => p2.id ).empty?
72
+ end
73
+
74
+
75
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sogilis-moxie_forum
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 8
9
+ version: 0.2.8
10
+ platform: ruby
11
+ authors:
12
+ - Keith Schacht, Guillaume Hammadi
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-15 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: ghammadi@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README.rdoc
29
+ files:
30
+ - app/controllers/moxie/admin/forums_controller.rb
31
+ - app/controllers/moxie/admin_controller.rb
32
+ - app/controllers/moxie/forums_controller.rb
33
+ - app/controllers/moxie/posts_controller.rb
34
+ - app/controllers/moxie/topics_controller.rb
35
+ - app/helpers/moxie/application_helper.rb
36
+ - app/helpers/moxie/forums_helper.rb
37
+ - app/models/moxie/forum.rb
38
+ - app/models/moxie/post.rb
39
+ - app/models/moxie/topic.rb
40
+ - app/views/layouts/forums.html.erb
41
+ - app/views/moxie/admin/forums/_form.html.erb
42
+ - app/views/moxie/admin/forums/edit.html.erb
43
+ - app/views/moxie/admin/forums/index.html.erb
44
+ - app/views/moxie/admin/forums/new.html.erb
45
+ - app/views/moxie/admin/forums/show.html.erb
46
+ - app/views/moxie/admin/index.html.erb
47
+ - app/views/moxie/forums/authorization_error.html.erb
48
+ - app/views/moxie/forums/index.html.erb
49
+ - app/views/moxie/forums/show.html.erb
50
+ - app/views/moxie/posts/_form.html.erb
51
+ - app/views/moxie/posts/_post.html.erb
52
+ - app/views/moxie/topics/_form.html.erb
53
+ - app/views/moxie/topics/new.html.erb
54
+ - app/views/moxie/topics/show.html.erb
55
+ - config/routes.rb
56
+ - lib/application_helper.rb
57
+ - lib/moxie_forum.rb
58
+ - lib/moxie_forum/acts_as_moxie_user/base.rb
59
+ - lib/moxie_forum/engine.rb
60
+ - lib/rails/generators/moxie_forum/moxie_forum_generator.rb
61
+ - lib/rails/generators/moxie_forum/templates/config.yml
62
+ - lib/rails/generators/moxie_forum/templates/initializer.rb
63
+ - lib/rails/generators/moxie_forum/templates/migration.rb
64
+ - lib/rails/generators/moxie_forum/templates/schema.rb
65
+ - lib/rails/railties/tasks.rake
66
+ - lib/tasks/tasks.rb
67
+ - public/images/gradient_grey.png
68
+ - public/stylesheets/moxie_forum.css
69
+ - README.rdoc
70
+ - test/generators/moxie_forum_generator_test.rb
71
+ - test/test_helper.rb
72
+ - test/unit/forum_test.rb
73
+ has_rdoc: true
74
+ homepage:
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options: []
79
+
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project:
101
+ rubygems_version: 1.3.7
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Fantastic forum software for Rails 3
105
+ test_files:
106
+ - test/generators/moxie_forum_generator_test.rb
107
+ - test/test_helper.rb
108
+ - test/unit/forum_test.rb