moxie_forum 0.2.4
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.
- data/README.rdoc +47 -0
- data/app/controllers/moxie/admin/forums_controller.rb +71 -0
- data/app/controllers/moxie/admin_controller.rb +10 -0
- data/app/controllers/moxie/forums_controller.rb +29 -0
- data/app/controllers/moxie/posts_controller.rb +52 -0
- data/app/controllers/moxie/topics_controller.rb +63 -0
- data/app/helpers/moxie/application_helper.rb +3 -0
- data/app/helpers/moxie/forums_helper.rb +5 -0
- data/app/models/moxie/forum.rb +16 -0
- data/app/models/moxie/post.rb +34 -0
- data/app/models/moxie/topic.rb +39 -0
- data/app/views/layouts/forums.html.erb +14 -0
- data/app/views/moxie/admin/forums/_form.html.erb +28 -0
- data/app/views/moxie/admin/forums/edit.html.erb +6 -0
- data/app/views/moxie/admin/forums/index.html.erb +28 -0
- data/app/views/moxie/admin/forums/new.html.erb +5 -0
- data/app/views/moxie/admin/forums/show.html.erb +20 -0
- data/app/views/moxie/admin/index.html.erb +3 -0
- data/app/views/moxie/forums/authorization_error.html.erb +4 -0
- data/app/views/moxie/forums/index.html.erb +20 -0
- data/app/views/moxie/forums/show.html.erb +38 -0
- data/app/views/moxie/posts/_form.html.erb +51 -0
- data/app/views/moxie/posts/_post.html.erb +23 -0
- data/app/views/moxie/topics/_form.html.erb +50 -0
- data/app/views/moxie/topics/new.html.erb +1 -0
- data/app/views/moxie/topics/show.html.erb +12 -0
- data/config/routes.rb +26 -0
- data/lib/application_helper.rb +24 -0
- data/lib/moxie_forum/acts_as_moxie_user/base.rb +53 -0
- data/lib/moxie_forum/engine.rb +54 -0
- data/lib/moxie_forum.rb +4 -0
- data/lib/rails/generators/moxie_forum/moxie_forum_generator.rb +76 -0
- data/lib/rails/generators/moxie_forum/templates/config.yml +5 -0
- data/lib/rails/generators/moxie_forum/templates/initializer.rb +15 -0
- data/lib/rails/generators/moxie_forum/templates/migration.rb +20 -0
- data/lib/rails/generators/moxie_forum/templates/schema.rb +43 -0
- data/lib/rails/railties/tasks.rake +8 -0
- data/lib/tasks/tasks.rb +9 -0
- data/public/images/gradient_grey.png +0 -0
- data/public/stylesheets/moxie_forum.css +223 -0
- data/test/generators/moxie_forum_generator_test.rb +10 -0
- data/test/test_helper.rb +77 -0
- data/test/unit/forum_test.rb +78 -0
- metadata +111 -0
data/test/test_helper.rb
ADDED
@@ -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,78 @@
|
|
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
|
+
:title => "I forgot",
|
37
|
+
:body => "Don't forget to introduce yourself." )
|
38
|
+
|
39
|
+
assert moxie_topics(:welcome).posts.include? p
|
40
|
+
assert_equal moxie_topics(:welcome).posts.length, start_count + 1
|
41
|
+
p.destroy
|
42
|
+
assert_equal moxie_topics(:welcome).posts.length, start_count
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_topics_and_posts_removed_upon_forum_delete
|
46
|
+
f = Moxie::Forum.create( :title => "Dummy forum" )
|
47
|
+
t1 = Moxie::Topic.create( :forum_id => f.id,
|
48
|
+
:author_id => 0,
|
49
|
+
:title => "Dummy topic 1" )
|
50
|
+
t2 = Moxie::Topic.create( :forum_id => f.id,
|
51
|
+
:author_id => 0,
|
52
|
+
:title => "Dummy topic 2" )
|
53
|
+
p1 = Moxie::Post.create( :topic_id => t1.id,
|
54
|
+
:author_id => 0,
|
55
|
+
:title => "Dummy post 1.1",
|
56
|
+
:body => "body" )
|
57
|
+
p2 = Moxie::Post.create( :topic_id => t1.id,
|
58
|
+
:author_id => 0,
|
59
|
+
:title => "Dummy post 1.2",
|
60
|
+
:body => "body" )
|
61
|
+
|
62
|
+
assert f.topics.include? t1
|
63
|
+
assert t1.posts.include? p1
|
64
|
+
assert ! Moxie::Forum.where( :id => f.id ).empty?
|
65
|
+
assert ! Moxie::Topic.where( :id => t1.id ).empty?
|
66
|
+
assert ! Moxie::Post.where( :id => p1.id ).empty?
|
67
|
+
|
68
|
+
f.destroy
|
69
|
+
|
70
|
+
assert Moxie::Forum.where( :id => f.id ).empty?
|
71
|
+
assert Moxie::Topic.where( :id => t1.id ).empty?
|
72
|
+
assert Moxie::Topic.where( :id => t2.id ).empty?
|
73
|
+
assert Moxie::Post.where( :id => p1.id ).empty?
|
74
|
+
assert Moxie::Post.where( :id => p2.id ).empty?
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moxie_forum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Keith Schacht
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-30 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: krschacht@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- app/controllers/moxie/admin/forums_controller.rb
|
32
|
+
- app/controllers/moxie/admin_controller.rb
|
33
|
+
- app/controllers/moxie/forums_controller.rb
|
34
|
+
- app/controllers/moxie/posts_controller.rb
|
35
|
+
- app/controllers/moxie/topics_controller.rb
|
36
|
+
- app/helpers/moxie/application_helper.rb
|
37
|
+
- app/helpers/moxie/forums_helper.rb
|
38
|
+
- app/models/moxie/forum.rb
|
39
|
+
- app/models/moxie/post.rb
|
40
|
+
- app/models/moxie/topic.rb
|
41
|
+
- app/views/layouts/forums.html.erb
|
42
|
+
- app/views/moxie/admin/forums/_form.html.erb
|
43
|
+
- app/views/moxie/admin/forums/edit.html.erb
|
44
|
+
- app/views/moxie/admin/forums/index.html.erb
|
45
|
+
- app/views/moxie/admin/forums/new.html.erb
|
46
|
+
- app/views/moxie/admin/forums/show.html.erb
|
47
|
+
- app/views/moxie/admin/index.html.erb
|
48
|
+
- app/views/moxie/forums/authorization_error.html.erb
|
49
|
+
- app/views/moxie/forums/index.html.erb
|
50
|
+
- app/views/moxie/forums/show.html.erb
|
51
|
+
- app/views/moxie/posts/_form.html.erb
|
52
|
+
- app/views/moxie/posts/_post.html.erb
|
53
|
+
- app/views/moxie/topics/_form.html.erb
|
54
|
+
- app/views/moxie/topics/new.html.erb
|
55
|
+
- app/views/moxie/topics/show.html.erb
|
56
|
+
- config/routes.rb
|
57
|
+
- lib/application_helper.rb
|
58
|
+
- lib/moxie_forum.rb
|
59
|
+
- lib/moxie_forum/acts_as_moxie_user/base.rb
|
60
|
+
- lib/moxie_forum/engine.rb
|
61
|
+
- lib/rails/generators/moxie_forum/moxie_forum_generator.rb
|
62
|
+
- lib/rails/generators/moxie_forum/templates/config.yml
|
63
|
+
- lib/rails/generators/moxie_forum/templates/initializer.rb
|
64
|
+
- lib/rails/generators/moxie_forum/templates/migration.rb
|
65
|
+
- lib/rails/generators/moxie_forum/templates/schema.rb
|
66
|
+
- lib/rails/railties/tasks.rake
|
67
|
+
- lib/tasks/tasks.rb
|
68
|
+
- public/images/gradient_grey.png
|
69
|
+
- public/stylesheets/moxie_forum.css
|
70
|
+
- README.rdoc
|
71
|
+
- test/generators/moxie_forum_generator_test.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
- test/unit/forum_test.rb
|
74
|
+
has_rdoc: true
|
75
|
+
homepage:
|
76
|
+
licenses: []
|
77
|
+
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options:
|
80
|
+
- --charset=UTF-8
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
version: "0"
|
101
|
+
requirements: []
|
102
|
+
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 1.3.7
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: Fantastic forum software for Rails 3
|
108
|
+
test_files:
|
109
|
+
- test/generators/moxie_forum_generator_test.rb
|
110
|
+
- test/test_helper.rb
|
111
|
+
- test/unit/forum_test.rb
|