muck-comments 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/app/controllers/muck/comments_controller.rb +5 -2
- data/app/helpers/muck_comments_helper.rb +8 -8
- data/app/views/comments/_comment.html.erb +1 -1
- data/app/views/comments/_simple_comment.html.erb +1 -1
- data/muck-comments.gemspec +14 -22
- data/test/rails_root/Rakefile +2 -1
- data/test/rails_root/app/models/profile.rb +3 -0
- data/test/rails_root/app/models/user.rb +1 -0
- data/test/rails_root/config/environment.rb +9 -7
- data/test/rails_root/config/environments/test.rb +0 -14
- data/test/rails_root/db/migrate/20090402234137_create_languages.rb +1 -1
- data/test/rails_root/db/migrate/20090512013727_create_profiles.rb +21 -0
- data/test/rails_root/public/images/icons/external.png +0 -0
- data/test/rails_root/public/images/icons/feed.png +0 -0
- data/test/rails_root/public/images/icons/pending.png +0 -0
- data/test/rails_root/public/javascripts/jquery/jrails.js +1 -0
- data/test/rails_root/public/stylesheets/muck-activities.css +39 -0
- data/test/rails_root/test/test_helper.rb +5 -42
- metadata +14 -21
- data/test/rails_root/Capfile +0 -3
- data/test/rails_root/db/migrate/20090602041838_create_users.rb +0 -39
- data/test/rails_root/test/factories.rb +0 -75
- data/test/rails_root/test/mocks/development/.keep +0 -0
- data/test/rails_root/test/mocks/test/.keep +0 -0
- data/test/rails_root/test/shoulda_macros/controller.rb +0 -49
- data/test/rails_root/test/shoulda_macros/forms.rb +0 -32
- data/test/rails_root/test/shoulda_macros/models.rb +0 -50
- data/test/rails_root/test/shoulda_macros/pagination.rb +0 -53
- data/test/rails_root/test/shoulda_macros/plugins.rb +0 -34
data/MIT-LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -49,10 +49,10 @@ begin
|
|
49
49
|
Jeweler::Tasks.new do |gemspec|
|
50
50
|
gemspec.name = "muck-comments"
|
51
51
|
gemspec.summary = "The comment engine for the muck system"
|
52
|
-
gemspec.email = "
|
53
|
-
gemspec.homepage = "http://github.com/
|
52
|
+
gemspec.email = "justin@tatemae.com"
|
53
|
+
gemspec.homepage = "http://github.com/tatemae/muck_comments"
|
54
54
|
gemspec.description = "The comment engine for the muck system."
|
55
|
-
gemspec.authors = ["Justin Ball"]
|
55
|
+
gemspec.authors = ["Justin Ball", "Joel Duffin"]
|
56
56
|
gemspec.rubyforge_project = 'muck-comments'
|
57
57
|
gemspec.add_dependency "muck-engine"
|
58
58
|
gemspec.add_dependency "muck-users"
|
@@ -62,5 +62,5 @@ begin
|
|
62
62
|
end
|
63
63
|
Jeweler::GemcutterTasks.new
|
64
64
|
rescue LoadError
|
65
|
-
puts "Jeweler not available. Install it with: sudo gem install
|
65
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
66
66
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.15
|
@@ -104,12 +104,15 @@ class Muck::CommentsController < ApplicationController
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def get_parent_comment_html(parent, comment)
|
107
|
+
truncate_comment = false
|
108
|
+
length = 30
|
109
|
+
omission = '...'
|
107
110
|
render_as_html do
|
108
|
-
render_to_string(:partial => "#{parent.class.to_s.tableize}/comment", :object => comment, :locals => {:comment_owner => parent})
|
111
|
+
render_to_string(:partial => "#{parent.class.to_s.tableize}/comment", :object => comment, :locals => {:comment_owner => parent, :truncate_comment => truncate_comment, :length => length, :omission => omission})
|
109
112
|
end
|
110
113
|
rescue ActionView::MissingTemplate
|
111
114
|
render_as_html do
|
112
|
-
render_to_string(:partial => "comments/comment", :object => comment, :locals => {:comment_owner => parent})
|
115
|
+
render_to_string(:partial => "comments/comment", :object => comment, :locals => {:comment_owner => parent, :truncate_comment => truncate_comment, :length => length, :omission => omission})
|
113
116
|
end
|
114
117
|
#I18n.t('muck.comments.missing_comment_template_error', :partial => "#{parent.class.to_s.tableize}/comment")
|
115
118
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module MuckCommentsHelper
|
2
2
|
|
3
|
-
def latest_simple_comments(limit = 5,
|
4
|
-
render :partial => 'comments/simple_comment', :collection => Comment.by_newest.limit(limit), :locals => { :
|
3
|
+
def latest_simple_comments(limit = 5, truncate_comment = true, length = 30, omission = '...')
|
4
|
+
render :partial => 'comments/simple_comment', :collection => Comment.by_newest.limit(limit), :locals => { :truncate_comment => truncate_comment, :length => length, :omission => omission }
|
5
5
|
end
|
6
6
|
|
7
|
-
def latest_comments(limit = 5,
|
8
|
-
render :partial => 'comments/comment', :collection => Comment.by_newest.limit(limit), :locals => { :
|
7
|
+
def latest_comments(limit = 5, truncate_comment = true, length = 30, omission = '...')
|
8
|
+
render :partial => 'comments/comment', :collection => Comment.by_newest.limit(limit), :locals => { :truncate_comment => truncate_comment, :length => length, :omission => omission }
|
9
9
|
end
|
10
10
|
|
11
|
-
def show_comments(comments)
|
12
|
-
render :partial => 'comments/comment', :collection => comments
|
11
|
+
def show_comments(comments, truncate_comment = false, length = 30, omission = '...')
|
12
|
+
render :partial => 'comments/comment', :collection => comments, :locals => { :truncate_comment => truncate_comment, :length => length, :omission => omission }
|
13
13
|
end
|
14
14
|
|
15
15
|
# parent is the object to which the comments will be attached
|
@@ -41,8 +41,8 @@ module MuckCommentsHelper
|
|
41
41
|
:delete_path => comment_path(comment, :format => 'js') }
|
42
42
|
end
|
43
43
|
|
44
|
-
def limit_comment(text,
|
45
|
-
if
|
44
|
+
def limit_comment(text, truncate_comment = false, length = 30, omission = '...')
|
45
|
+
if truncate_comment
|
46
46
|
html_summarize(text, length, omission)
|
47
47
|
else
|
48
48
|
text
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div id="<%= comment.dom_id %>" class="comment_holder delete-container">
|
2
2
|
<div class="commentor-icon"><%= icon comment.user %></div>
|
3
3
|
<p><span class="commentor"><%= link_to comment.user.try(:display_name), comment.user %></span>
|
4
|
-
<%= h limit_comment(comment.body,
|
4
|
+
<%= h limit_comment(comment.body, truncate_comment, length, omission) %></p>
|
5
5
|
<%= delete_comment(comment, :image) if comment.can_edit?(current_user) %>
|
6
6
|
<span class="comment-time"><%= t("muck.general.time_ago", :time_in_words => time_ago_in_words(comment.created_at)) %></span></p>
|
7
7
|
</div>
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<div id="<%= simple_comment.dom_id %>" class="simple-comment">
|
2
2
|
<div class="commentor-icon"><%= icon simple_comment.user %></div>
|
3
|
-
<div class="comment-body"><%= h limit_comment(simple_comment.body,
|
3
|
+
<div class="comment-body"><%= h limit_comment(simple_comment.body, truncate_comment, length, omission) %></div>
|
4
4
|
</div>
|
data/muck-comments.gemspec
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{muck-comments}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.15"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Justin Ball"]
|
12
|
-
s.date = %q{2009-11-
|
11
|
+
s.authors = ["Justin Ball", "Joel Duffin"]
|
12
|
+
s.date = %q{2009-11-13}
|
13
13
|
s.description = %q{The comment engine for the muck system.}
|
14
|
-
s.email = %q{
|
14
|
+
s.email = %q{justin@tatemae.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
@@ -93,13 +93,13 @@ Gem::Specification.new do |s|
|
|
93
93
|
"tasks/muck_comments_tasks.rake",
|
94
94
|
"test/rails_root/.gitignore",
|
95
95
|
"test/rails_root/.rake_tasks",
|
96
|
-
"test/rails_root/Capfile",
|
97
96
|
"test/rails_root/Rakefile",
|
98
97
|
"test/rails_root/app/controllers/application_controller.rb",
|
99
98
|
"test/rails_root/app/controllers/default_controller.rb",
|
100
99
|
"test/rails_root/app/helpers/application_helper.rb",
|
101
100
|
"test/rails_root/app/models/.keep",
|
102
101
|
"test/rails_root/app/models/comment.rb",
|
102
|
+
"test/rails_root/app/models/profile.rb",
|
103
103
|
"test/rails_root/app/models/user.rb",
|
104
104
|
"test/rails_root/app/models/user_session.rb",
|
105
105
|
"test/rails_root/app/views/default/index.html.erb",
|
@@ -125,7 +125,7 @@ Gem::Specification.new do |s|
|
|
125
125
|
"test/rails_root/db/migrate/20090402234137_create_languages.rb",
|
126
126
|
"test/rails_root/db/migrate/20090426041056_create_countries.rb",
|
127
127
|
"test/rails_root/db/migrate/20090426041103_create_states.rb",
|
128
|
-
"test/rails_root/db/migrate/
|
128
|
+
"test/rails_root/db/migrate/20090512013727_create_profiles.rb",
|
129
129
|
"test/rails_root/db/migrate/20090608073052_create_friends.rb",
|
130
130
|
"test/rails_root/db/migrate/20090613173314_create_comments.rb",
|
131
131
|
"test/rails_root/db/migrate/20090703055724_add_contents.rb",
|
@@ -177,10 +177,13 @@ Gem::Specification.new do |s|
|
|
177
177
|
"test/rails_root/public/images/icons/comment.png",
|
178
178
|
"test/rails_root/public/images/icons/delete.png",
|
179
179
|
"test/rails_root/public/images/icons/exclaim.png",
|
180
|
+
"test/rails_root/public/images/icons/external.png",
|
181
|
+
"test/rails_root/public/images/icons/feed.png",
|
180
182
|
"test/rails_root/public/images/icons/grey_guy.png",
|
181
183
|
"test/rails_root/public/images/icons/hide.png",
|
182
184
|
"test/rails_root/public/images/icons/information.png",
|
183
185
|
"test/rails_root/public/images/icons/minus.png",
|
186
|
+
"test/rails_root/public/images/icons/pending.png",
|
184
187
|
"test/rails_root/public/images/icons/question.png",
|
185
188
|
"test/rails_root/public/images/icons/search_box.png",
|
186
189
|
"test/rails_root/public/images/icons/star.png",
|
@@ -207,6 +210,7 @@ Gem::Specification.new do |s|
|
|
207
210
|
"test/rails_root/public/javascripts/jquery/jquery.jgrowl.js",
|
208
211
|
"test/rails_root/public/javascripts/jquery/jquery.js",
|
209
212
|
"test/rails_root/public/javascripts/jquery/jquery.tips.js",
|
213
|
+
"test/rails_root/public/javascripts/jquery/jrails.js",
|
210
214
|
"test/rails_root/public/javascripts/muck.js",
|
211
215
|
"test/rails_root/public/javascripts/muck_activities.js",
|
212
216
|
"test/rails_root/public/javascripts/muck_time/en.js",
|
@@ -313,6 +317,7 @@ Gem::Specification.new do |s|
|
|
313
317
|
"test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png",
|
314
318
|
"test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png",
|
315
319
|
"test/rails_root/public/stylesheets/jquery/ui-lightness/jquery-ui-1.7.1.custom.css",
|
320
|
+
"test/rails_root/public/stylesheets/muck-activities.css",
|
316
321
|
"test/rails_root/public/stylesheets/reset.css",
|
317
322
|
"test/rails_root/public/stylesheets/styles.css",
|
318
323
|
"test/rails_root/public/stylesheets/themes/blue/styles.css",
|
@@ -334,16 +339,8 @@ Gem::Specification.new do |s|
|
|
334
339
|
"test/rails_root/script/process/spawner",
|
335
340
|
"test/rails_root/script/runner",
|
336
341
|
"test/rails_root/script/server",
|
337
|
-
"test/rails_root/test/factories.rb",
|
338
342
|
"test/rails_root/test/functional/.keep",
|
339
343
|
"test/rails_root/test/functional/comments_controller_test.rb",
|
340
|
-
"test/rails_root/test/mocks/development/.keep",
|
341
|
-
"test/rails_root/test/mocks/test/.keep",
|
342
|
-
"test/rails_root/test/shoulda_macros/controller.rb",
|
343
|
-
"test/rails_root/test/shoulda_macros/forms.rb",
|
344
|
-
"test/rails_root/test/shoulda_macros/models.rb",
|
345
|
-
"test/rails_root/test/shoulda_macros/pagination.rb",
|
346
|
-
"test/rails_root/test/shoulda_macros/plugins.rb",
|
347
344
|
"test/rails_root/test/test_helper.rb",
|
348
345
|
"test/rails_root/test/unit/.keep",
|
349
346
|
"test/rails_root/test/unit/comment_mailer_test.rb",
|
@@ -354,7 +351,7 @@ Gem::Specification.new do |s|
|
|
354
351
|
"test/rails_root/vendor/plugins/ssl_requirement/test/ssl_requirement_test.rb",
|
355
352
|
"uninstall.rb"
|
356
353
|
]
|
357
|
-
s.homepage = %q{http://github.com/
|
354
|
+
s.homepage = %q{http://github.com/tatemae/muck_comments}
|
358
355
|
s.rdoc_options = ["--charset=UTF-8"]
|
359
356
|
s.require_paths = ["lib"]
|
360
357
|
s.rubyforge_project = %q{muck-comments}
|
@@ -365,6 +362,7 @@ Gem::Specification.new do |s|
|
|
365
362
|
"test/rails_root/app/controllers/default_controller.rb",
|
366
363
|
"test/rails_root/app/helpers/application_helper.rb",
|
367
364
|
"test/rails_root/app/models/comment.rb",
|
365
|
+
"test/rails_root/app/models/profile.rb",
|
368
366
|
"test/rails_root/app/models/user.rb",
|
369
367
|
"test/rails_root/app/models/user_session.rb",
|
370
368
|
"test/rails_root/config/boot.rb",
|
@@ -384,7 +382,7 @@ Gem::Specification.new do |s|
|
|
384
382
|
"test/rails_root/db/migrate/20090402234137_create_languages.rb",
|
385
383
|
"test/rails_root/db/migrate/20090426041056_create_countries.rb",
|
386
384
|
"test/rails_root/db/migrate/20090426041103_create_states.rb",
|
387
|
-
"test/rails_root/db/migrate/
|
385
|
+
"test/rails_root/db/migrate/20090512013727_create_profiles.rb",
|
388
386
|
"test/rails_root/db/migrate/20090608073052_create_friends.rb",
|
389
387
|
"test/rails_root/db/migrate/20090613173314_create_comments.rb",
|
390
388
|
"test/rails_root/db/migrate/20090703055724_add_contents.rb",
|
@@ -402,13 +400,7 @@ Gem::Specification.new do |s|
|
|
402
400
|
"test/rails_root/features/support/paths.rb",
|
403
401
|
"test/rails_root/public/dispatch.rb",
|
404
402
|
"test/rails_root/script/create_project.rb",
|
405
|
-
"test/rails_root/test/factories.rb",
|
406
403
|
"test/rails_root/test/functional/comments_controller_test.rb",
|
407
|
-
"test/rails_root/test/shoulda_macros/controller.rb",
|
408
|
-
"test/rails_root/test/shoulda_macros/forms.rb",
|
409
|
-
"test/rails_root/test/shoulda_macros/models.rb",
|
410
|
-
"test/rails_root/test/shoulda_macros/pagination.rb",
|
411
|
-
"test/rails_root/test/shoulda_macros/plugins.rb",
|
412
404
|
"test/rails_root/test/test_helper.rb",
|
413
405
|
"test/rails_root/test/unit/comment_mailer_test.rb",
|
414
406
|
"test/rails_root/test/unit/comment_test.rb",
|
data/test/rails_root/Rakefile
CHANGED
@@ -13,11 +13,12 @@ require 'muck_comments/tasks'
|
|
13
13
|
require 'muck_engine/tasks'
|
14
14
|
require 'muck_users/tasks'
|
15
15
|
require 'muck_activities/tasks'
|
16
|
+
require 'muck_profiles/tasks'
|
16
17
|
|
17
18
|
namespace :muck do
|
18
19
|
|
19
20
|
def muck_gems
|
20
|
-
['
|
21
|
+
['muck-engine', 'muck-users', 'muck-activities', 'muck-comments', 'muck-profiles']
|
21
22
|
end
|
22
23
|
|
23
24
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
RAILS_GEM_VERSION = '2.3.
|
1
|
+
RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), 'boot')
|
4
4
|
|
@@ -15,16 +15,18 @@ end
|
|
15
15
|
|
16
16
|
Rails::Initializer.run do |config|
|
17
17
|
config.time_zone = 'UTC'
|
18
|
-
config.gem
|
19
|
-
config.gem "
|
20
|
-
config.gem "
|
18
|
+
config.gem "will_paginate"
|
19
|
+
config.gem "authlogic"
|
20
|
+
config.gem "searchlogic"
|
21
21
|
config.gem "bcrypt-ruby", :lib => "bcrypt", :version => ">=2.0.5"
|
22
|
-
config.gem
|
23
|
-
config.gem "
|
24
|
-
config.gem "friendly_id"
|
22
|
+
config.gem "acts-as-taggable-on"
|
23
|
+
config.gem "awesome_nested_set"
|
24
|
+
config.gem "friendly_id"
|
25
|
+
config.gem "paperclip"
|
25
26
|
config.gem "babelphish"
|
26
27
|
config.gem 'muck-engine', :lib => 'muck_engine'
|
27
28
|
config.gem 'muck-users', :lib => 'muck_users'
|
29
|
+
config.gem 'muck-profiles', :lib => 'muck_profiles'
|
28
30
|
config.gem 'muck-activities', :lib => 'muck_activities'
|
29
31
|
config.plugin_locators << TestGemLocator
|
30
32
|
end
|
@@ -26,17 +26,3 @@ HOST = "localhost"
|
|
26
26
|
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
27
27
|
# like if you have constraints or database-specific column types
|
28
28
|
# config.active_record.schema_format = :sql
|
29
|
-
|
30
|
-
config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com'
|
31
|
-
config.gem 'thoughtbot-shoulda', :lib => 'shoulda', :source => 'http://gems.github.com'
|
32
|
-
config.gem 'treetop', :version => '>=1.2.4'
|
33
|
-
config.gem 'term-ansicolor', :version => '>=1.0.3', :lib => 'term/ansicolor'
|
34
|
-
config.gem 'polyglot', :version => '>=0.2.4'
|
35
|
-
config.gem "rcov", :version => '>=0.8.1.2.0'
|
36
|
-
|
37
|
-
# only required if you want to use selenium for testing
|
38
|
-
config.gem 'selenium-client', :lib => 'selenium/client'
|
39
|
-
config.gem 'bmabey-database_cleaner', :lib => 'database_cleaner', :source => 'http://gems.github.com'
|
40
|
-
|
41
|
-
require 'factory_girl'
|
42
|
-
begin require 'redgreen'; rescue LoadError; end
|
@@ -5,7 +5,7 @@ class CreateLanguages < ActiveRecord::Migration
|
|
5
5
|
t.string :english_name
|
6
6
|
t.string :locale
|
7
7
|
t.boolean :supported, :default => true
|
8
|
-
t.
|
8
|
+
t.boolean :is_default, :default => false
|
9
9
|
end
|
10
10
|
add_index :languages, :name
|
11
11
|
add_index :languages, :locale
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateProfiles < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
|
5
|
+
create_table :profiles, :force => true do |t|
|
6
|
+
t.integer :user_id
|
7
|
+
t.string :photo_file_name
|
8
|
+
t.string :photo_content_type
|
9
|
+
t.integer :photo_file_size
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :profiles, ['user_id']
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
drop_table :profiles
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
(function($){$().ajaxSend(function(a,xhr,s){xhr.setRequestHeader("Accept","text/javascript, text/html, application/xml, text/xml, */*")})})(jQuery);(function($){$.fn.reset=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset()}})};$.fn.enable=function(){return this.each(function(){this.disabled=false})};$.fn.disable=function(){return this.each(function(){this.disabled=true})}})(jQuery);(function($){$.extend({fieldEvent:function(el,obs){var field=el[0]||el,e="change";if(field.type=="radio"||field.type=="checkbox"){e="click"}else{if(obs&&field.type=="text"||field.type=="textarea"){e="keyup"}}return e}});$.fn.extend({delayedObserver:function(delay,callback){var el=$(this);if(typeof window.delayedObserverStack=="undefined"){window.delayedObserverStack=[]}if(typeof window.delayedObserverCallback=="undefined"){window.delayedObserverCallback=function(stackPos){observed=window.delayedObserverStack[stackPos];if(observed.timer){clearTimeout(observed.timer)}observed.timer=setTimeout(function(){observed.timer=null;observed.callback(observed.obj,observed.obj.formVal())},observed.delay*1000);observed.oldVal=observed.obj.formVal()}}window.delayedObserverStack.push({obj:el,timer:null,delay:delay,oldVal:el.formVal(),callback:callback});var stackPos=window.delayedObserverStack.length-1;if(el[0].tagName=="FORM"){$(":input",el).each(function(){var field=$(this);field.bind($.fieldEvent(field,delay),function(){observed=window.delayedObserverStack[stackPos];if(observed.obj.formVal()==observed.obj.oldVal){return}else{window.delayedObserverCallback(stackPos)}})})}else{el.bind($.fieldEvent(el,delay),function(){observed=window.delayedObserverStack[stackPos];if(observed.obj.formVal()==observed.obj.oldVal){return}else{window.delayedObserverCallback(stackPos)}})}},formVal:function(){var el=this[0];if(el.tagName=="FORM"){return this.serialize()}if(el.type=="checkbox"||self.type=="radio"){return this.filter("input:checked").val()||""}else{return this.val()}}})})(jQuery);(function($){$.fn.extend({visualEffect:function(o){e=o.replace(/\_(.)/g,function(m,l){return l.toUpperCase()});return eval("$(this)."+e+"()")},appear:function(speed,callback){return this.fadeIn(speed,callback)},blindDown:function(speed,callback){return this.show("blind",{direction:"vertical"},speed,callback)},blindUp:function(speed,callback){return this.hide("blind",{direction:"vertical"},speed,callback)},blindRight:function(speed,callback){return this.show("blind",{direction:"horizontal"},speed,callback)},blindLeft:function(speed,callback){this.hide("blind",{direction:"horizontal"},speed,callback);return this},dropOut:function(speed,callback){return this.hide("drop",{direction:"down"},speed,callback)},dropIn:function(speed,callback){return this.show("drop",{direction:"up"},speed,callback)},fade:function(speed,callback){return this.fadeOut(speed,callback)},fadeToggle:function(speed,callback){return this.animate({opacity:"toggle"},speed,callback)},fold:function(speed,callback){return this.hide("fold",{},speed,callback)},foldOut:function(speed,callback){return this.show("fold",{},speed,callback)},grow:function(speed,callback){return this.show("scale",{},speed,callback)},highlight:function(speed,callback){return this.show("highlight",{},speed,callback)},puff:function(speed,callback){return this.hide("puff",{},speed,callback)},pulsate:function(speed,callback){return this.show("pulsate",{},speed,callback)},shake:function(speed,callback){return this.show("shake",{},speed,callback)},shrink:function(speed,callback){return this.hide("scale",{},speed,callback)},squish:function(speed,callback){return this.hide("scale",{origin:["top","left"]},speed,callback)},slideUp:function(speed,callback){return this.hide("slide",{direction:"up"},speed,callback)},slideDown:function(speed,callback){return this.show("slide",{direction:"up"},speed,callback)},switchOff:function(speed,callback){return this.hide("clip",{},speed,callback)},switchOn:function(speed,callback){return this.show("clip",{},speed,callback)}})})(jQuery);
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/* activity feed */
|
2
|
+
#activity-status-control{border:solid 1px #ccc;padding:10px 7px;background-color:#eee;}
|
3
|
+
#status-update-field{}
|
4
|
+
ul#status-menu{list-style:none;}
|
5
|
+
ul#status-menu li{float:left;display:inline;margin:0 5px;}
|
6
|
+
#status-update-button input{padding:0;}
|
7
|
+
.status-update-dim{}
|
8
|
+
.status-update-lit{}
|
9
|
+
ul#activity-filter{list-style:none;}
|
10
|
+
ul#activity-filter li{border-bottom:solid 1px #ccc;}
|
11
|
+
ul#activity-filter li a{text-decoration:none;}
|
12
|
+
ul#activity-filter li a:hover;{text-decoration:underline;}
|
13
|
+
ul#activity-filter li.current a{color:#5EAC18;}
|
14
|
+
.activity{clear:both;display:block;}
|
15
|
+
#activity-feed{margin:15px 0 0 0;}
|
16
|
+
#activity-feed-content .activity{margin:8px 0 4px 0;}
|
17
|
+
#activity-feed-content .activity-time{font-size:1em;font-color:#eee;clear:left;}
|
18
|
+
#activity-icon, .actor-icon{width:50px;float:left;margin:0 10px 10px 0;}
|
19
|
+
#activity-feed-content .actor, #current-status-name{font-weight:bolder;font-size:1.3em;}
|
20
|
+
.activity-time, .status-time{color:#777777;font-size:.9em;}
|
21
|
+
p#current-status-text, .activity-content p{margin:0;}
|
22
|
+
form.activity-delete {position:relative;display:inline;float:right;display:none;}
|
23
|
+
form.activity-delete input{padding:0;margin:0;width:15px;height:15px;position:absolute;right:0px;bottom:0px;}
|
24
|
+
.activity .activity-hover form.activity-delete{display:block;}
|
25
|
+
.welcome_activity{font-size:14px;}
|
26
|
+
a.upload-button{background:transparent url('/images/icons/button_background.png') no-repeat scroll left top;text-decoration:none;padding:0px 23px 1px 6px;color:#fff;font-weight:bold;}
|
27
|
+
a.upload-button:hover{background:transparent url('/images/icons/button_background.png') no-repeat scroll left bottom;}
|
28
|
+
/* comments under activity feed */
|
29
|
+
.activity-comment{border:1px solid #ccc;margin:2px 50px 2px 60px;padding:.5em;background-color:#eee;}
|
30
|
+
.activity-comment .actor-icon{width:40px;}
|
31
|
+
.activity-comment .actor-icon img{width:40px;height:40px;}
|
32
|
+
.activity-comment textarea.max{width:80%;height:30px;}
|
33
|
+
.activity-comment textarea.min{height:15px;width:50%;}
|
34
|
+
.activity-comment p{margin:0;}
|
35
|
+
.activity-comment .actor a{font-size:.8em;}
|
36
|
+
.activity form.comment-delete {position:relative;display:inline;float:right;}
|
37
|
+
.activity form.comment-delete input{padding:0;margin:0;width:15px;height:15px;position:absolute;right:0px;top:0px;}
|
38
|
+
.activity form.comment-delete{display:none;}
|
39
|
+
.activity .comment-hover form.comment-delete{display:block;}
|
@@ -1,48 +1,11 @@
|
|
1
1
|
$:.reject! { |e| e.include? 'TextMate' }
|
2
2
|
ENV["RAILS_ENV"] = "test"
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
4
|
-
|
5
|
-
require '
|
6
|
-
gem 'thoughtbot-factory_girl' # from github
|
7
|
-
require 'factory_girl'
|
4
|
+
gem 'muck-engine'
|
5
|
+
require 'muck_test_helper'
|
8
6
|
require 'authlogic/test_case'
|
9
|
-
require 'redgreen' rescue LoadError
|
10
|
-
require File.expand_path(File.dirname(__FILE__) + '/factories')
|
11
|
-
require File.join(File.dirname(__FILE__), 'shoulda_macros', 'controller')
|
12
|
-
require File.join(File.dirname(__FILE__), 'shoulda_macros', 'models')
|
13
|
-
|
14
|
-
class ActiveSupport::TestCase
|
15
|
-
self.use_transactional_fixtures = true
|
16
|
-
self.use_instantiated_fixtures = false
|
17
7
|
|
8
|
+
class ActiveSupport::TestCase
|
9
|
+
include MuckTestMethods
|
18
10
|
include Authlogic::TestCase
|
19
|
-
|
20
|
-
def login_as(user)
|
21
|
-
success = UserSession.create(user)
|
22
|
-
if !success
|
23
|
-
errors = user.errors.full_messages.to_sentence
|
24
|
-
message = 'User has not been activated' if !user.active?
|
25
|
-
raise "could not login as #{user.to_param}. Please make sure the user is valid. #{message} #{errors}"
|
26
|
-
end
|
27
|
-
UserSession.find
|
28
|
-
end
|
29
|
-
|
30
|
-
def assure_logout
|
31
|
-
user_session = UserSession.find
|
32
|
-
user_session.destroy if user_session
|
33
|
-
end
|
34
|
-
|
35
|
-
def ensure_flash(val)
|
36
|
-
assert_contains flash.values, val, ", Flash: #{flash.inspect}"
|
37
|
-
end
|
38
|
-
|
39
|
-
# For Selenium
|
40
|
-
# setup do |session|
|
41
|
-
# session.host! "localhost:3001"
|
42
|
-
# end
|
43
|
-
|
44
|
-
def make_parent_params(parent)
|
45
|
-
{ :parent_id => parent.id, :parent_type => parent.class.to_s }
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muck-comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
8
|
+
- Joel Duffin
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-11-
|
13
|
+
date: 2009-11-13 00:00:00 -07:00
|
13
14
|
default_executable:
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +34,7 @@ dependencies:
|
|
33
34
|
version: "0"
|
34
35
|
version:
|
35
36
|
description: The comment engine for the muck system.
|
36
|
-
email:
|
37
|
+
email: justin@tatemae.com
|
37
38
|
executables: []
|
38
39
|
|
39
40
|
extensions: []
|
@@ -118,13 +119,13 @@ files:
|
|
118
119
|
- tasks/muck_comments_tasks.rake
|
119
120
|
- test/rails_root/.gitignore
|
120
121
|
- test/rails_root/.rake_tasks
|
121
|
-
- test/rails_root/Capfile
|
122
122
|
- test/rails_root/Rakefile
|
123
123
|
- test/rails_root/app/controllers/application_controller.rb
|
124
124
|
- test/rails_root/app/controllers/default_controller.rb
|
125
125
|
- test/rails_root/app/helpers/application_helper.rb
|
126
126
|
- test/rails_root/app/models/.keep
|
127
127
|
- test/rails_root/app/models/comment.rb
|
128
|
+
- test/rails_root/app/models/profile.rb
|
128
129
|
- test/rails_root/app/models/user.rb
|
129
130
|
- test/rails_root/app/models/user_session.rb
|
130
131
|
- test/rails_root/app/views/default/index.html.erb
|
@@ -150,7 +151,7 @@ files:
|
|
150
151
|
- test/rails_root/db/migrate/20090402234137_create_languages.rb
|
151
152
|
- test/rails_root/db/migrate/20090426041056_create_countries.rb
|
152
153
|
- test/rails_root/db/migrate/20090426041103_create_states.rb
|
153
|
-
- test/rails_root/db/migrate/
|
154
|
+
- test/rails_root/db/migrate/20090512013727_create_profiles.rb
|
154
155
|
- test/rails_root/db/migrate/20090608073052_create_friends.rb
|
155
156
|
- test/rails_root/db/migrate/20090613173314_create_comments.rb
|
156
157
|
- test/rails_root/db/migrate/20090703055724_add_contents.rb
|
@@ -202,10 +203,13 @@ files:
|
|
202
203
|
- test/rails_root/public/images/icons/comment.png
|
203
204
|
- test/rails_root/public/images/icons/delete.png
|
204
205
|
- test/rails_root/public/images/icons/exclaim.png
|
206
|
+
- test/rails_root/public/images/icons/external.png
|
207
|
+
- test/rails_root/public/images/icons/feed.png
|
205
208
|
- test/rails_root/public/images/icons/grey_guy.png
|
206
209
|
- test/rails_root/public/images/icons/hide.png
|
207
210
|
- test/rails_root/public/images/icons/information.png
|
208
211
|
- test/rails_root/public/images/icons/minus.png
|
212
|
+
- test/rails_root/public/images/icons/pending.png
|
209
213
|
- test/rails_root/public/images/icons/question.png
|
210
214
|
- test/rails_root/public/images/icons/search_box.png
|
211
215
|
- test/rails_root/public/images/icons/star.png
|
@@ -232,6 +236,7 @@ files:
|
|
232
236
|
- test/rails_root/public/javascripts/jquery/jquery.jgrowl.js
|
233
237
|
- test/rails_root/public/javascripts/jquery/jquery.js
|
234
238
|
- test/rails_root/public/javascripts/jquery/jquery.tips.js
|
239
|
+
- test/rails_root/public/javascripts/jquery/jrails.js
|
235
240
|
- test/rails_root/public/javascripts/muck.js
|
236
241
|
- test/rails_root/public/javascripts/muck_activities.js
|
237
242
|
- test/rails_root/public/javascripts/muck_time/en.js
|
@@ -338,6 +343,7 @@ files:
|
|
338
343
|
- test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png
|
339
344
|
- test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png
|
340
345
|
- test/rails_root/public/stylesheets/jquery/ui-lightness/jquery-ui-1.7.1.custom.css
|
346
|
+
- test/rails_root/public/stylesheets/muck-activities.css
|
341
347
|
- test/rails_root/public/stylesheets/reset.css
|
342
348
|
- test/rails_root/public/stylesheets/styles.css
|
343
349
|
- test/rails_root/public/stylesheets/themes/blue/styles.css
|
@@ -359,16 +365,8 @@ files:
|
|
359
365
|
- test/rails_root/script/process/spawner
|
360
366
|
- test/rails_root/script/runner
|
361
367
|
- test/rails_root/script/server
|
362
|
-
- test/rails_root/test/factories.rb
|
363
368
|
- test/rails_root/test/functional/.keep
|
364
369
|
- test/rails_root/test/functional/comments_controller_test.rb
|
365
|
-
- test/rails_root/test/mocks/development/.keep
|
366
|
-
- test/rails_root/test/mocks/test/.keep
|
367
|
-
- test/rails_root/test/shoulda_macros/controller.rb
|
368
|
-
- test/rails_root/test/shoulda_macros/forms.rb
|
369
|
-
- test/rails_root/test/shoulda_macros/models.rb
|
370
|
-
- test/rails_root/test/shoulda_macros/pagination.rb
|
371
|
-
- test/rails_root/test/shoulda_macros/plugins.rb
|
372
370
|
- test/rails_root/test/test_helper.rb
|
373
371
|
- test/rails_root/test/unit/.keep
|
374
372
|
- test/rails_root/test/unit/comment_mailer_test.rb
|
@@ -379,7 +377,7 @@ files:
|
|
379
377
|
- test/rails_root/vendor/plugins/ssl_requirement/test/ssl_requirement_test.rb
|
380
378
|
- uninstall.rb
|
381
379
|
has_rdoc: true
|
382
|
-
homepage: http://github.com/
|
380
|
+
homepage: http://github.com/tatemae/muck_comments
|
383
381
|
licenses: []
|
384
382
|
|
385
383
|
post_install_message:
|
@@ -411,6 +409,7 @@ test_files:
|
|
411
409
|
- test/rails_root/app/controllers/default_controller.rb
|
412
410
|
- test/rails_root/app/helpers/application_helper.rb
|
413
411
|
- test/rails_root/app/models/comment.rb
|
412
|
+
- test/rails_root/app/models/profile.rb
|
414
413
|
- test/rails_root/app/models/user.rb
|
415
414
|
- test/rails_root/app/models/user_session.rb
|
416
415
|
- test/rails_root/config/boot.rb
|
@@ -430,7 +429,7 @@ test_files:
|
|
430
429
|
- test/rails_root/db/migrate/20090402234137_create_languages.rb
|
431
430
|
- test/rails_root/db/migrate/20090426041056_create_countries.rb
|
432
431
|
- test/rails_root/db/migrate/20090426041103_create_states.rb
|
433
|
-
- test/rails_root/db/migrate/
|
432
|
+
- test/rails_root/db/migrate/20090512013727_create_profiles.rb
|
434
433
|
- test/rails_root/db/migrate/20090608073052_create_friends.rb
|
435
434
|
- test/rails_root/db/migrate/20090613173314_create_comments.rb
|
436
435
|
- test/rails_root/db/migrate/20090703055724_add_contents.rb
|
@@ -448,13 +447,7 @@ test_files:
|
|
448
447
|
- test/rails_root/features/support/paths.rb
|
449
448
|
- test/rails_root/public/dispatch.rb
|
450
449
|
- test/rails_root/script/create_project.rb
|
451
|
-
- test/rails_root/test/factories.rb
|
452
450
|
- test/rails_root/test/functional/comments_controller_test.rb
|
453
|
-
- test/rails_root/test/shoulda_macros/controller.rb
|
454
|
-
- test/rails_root/test/shoulda_macros/forms.rb
|
455
|
-
- test/rails_root/test/shoulda_macros/models.rb
|
456
|
-
- test/rails_root/test/shoulda_macros/pagination.rb
|
457
|
-
- test/rails_root/test/shoulda_macros/plugins.rb
|
458
451
|
- test/rails_root/test/test_helper.rb
|
459
452
|
- test/rails_root/test/unit/comment_mailer_test.rb
|
460
453
|
- test/rails_root/test/unit/comment_test.rb
|
data/test/rails_root/Capfile
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
class CreateUsers < ActiveRecord::Migration
|
2
|
-
|
3
|
-
def self.up
|
4
|
-
create_table :users, :force => true do |t|
|
5
|
-
t.string :login
|
6
|
-
t.string :email
|
7
|
-
t.string :first_name
|
8
|
-
t.string :last_name
|
9
|
-
t.string :crypted_password
|
10
|
-
t.string :password_salt
|
11
|
-
t.string :persistence_token
|
12
|
-
t.string :single_access_token
|
13
|
-
t.string :perishable_token
|
14
|
-
t.integer :login_count, :null => false, :default => 0
|
15
|
-
t.integer :failed_login_count, :null => false, :default => 0
|
16
|
-
t.datetime :last_request_at
|
17
|
-
t.datetime :last_login_at
|
18
|
-
t.datetime :current_login_at
|
19
|
-
t.string :current_login_ip
|
20
|
-
t.string :last_login_ip
|
21
|
-
t.boolean :terms_of_service, :default => false, :null => false
|
22
|
-
t.string :time_zone, :default => "UTC"
|
23
|
-
t.datetime :disabled_at
|
24
|
-
t.datetime :activated_at
|
25
|
-
t.timestamps
|
26
|
-
end
|
27
|
-
|
28
|
-
add_index :users, :login
|
29
|
-
add_index :users, :email
|
30
|
-
add_index :users, :persistence_token
|
31
|
-
add_index :users, :perishable_token
|
32
|
-
add_index :users, :single_access_token
|
33
|
-
add_index :users, :last_request_at
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.down
|
37
|
-
drop_table :users
|
38
|
-
end
|
39
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
Factory.sequence :email do |n|
|
2
|
-
"somebody#{n}@example.com"
|
3
|
-
end
|
4
|
-
|
5
|
-
Factory.sequence :login do |n|
|
6
|
-
"inquire#{n}"
|
7
|
-
end
|
8
|
-
|
9
|
-
Factory.sequence :name do |n|
|
10
|
-
"a_name#{n}"
|
11
|
-
end
|
12
|
-
|
13
|
-
Factory.sequence :title do |n|
|
14
|
-
"a_title#{n}"
|
15
|
-
end
|
16
|
-
|
17
|
-
Factory.sequence :abbr do |n|
|
18
|
-
"abbr#{n}"
|
19
|
-
end
|
20
|
-
|
21
|
-
Factory.sequence :description do |n|
|
22
|
-
"This is the description: #{n}"
|
23
|
-
end
|
24
|
-
|
25
|
-
Factory.sequence :uri do |n|
|
26
|
-
"n#{n}.example.com"
|
27
|
-
end
|
28
|
-
|
29
|
-
Factory.define :state do |f|
|
30
|
-
f.name { Factory.next(:name) }
|
31
|
-
f.abbreviation { Factory.next(:abbr) }
|
32
|
-
f.country {|a| a.association(:country) }
|
33
|
-
end
|
34
|
-
|
35
|
-
Factory.define :country do |f|
|
36
|
-
f.name { Factory.next(:name) }
|
37
|
-
f.abbreviation { Factory.next(:abbr) }
|
38
|
-
end
|
39
|
-
|
40
|
-
Factory.define :user do |f|
|
41
|
-
f.login { Factory.next(:login) }
|
42
|
-
f.email { Factory.next(:email) }
|
43
|
-
f.password 'inquire_pass'
|
44
|
-
f.password_confirmation 'inquire_pass'
|
45
|
-
f.first_name 'test'
|
46
|
-
f.last_name 'guy'
|
47
|
-
f.terms_of_service true
|
48
|
-
f.activated_at DateTime.now
|
49
|
-
end
|
50
|
-
|
51
|
-
Factory.define :permission do |f|
|
52
|
-
f.role {|a| a.association(:role)}
|
53
|
-
f.user {|a| a.association(:user)}
|
54
|
-
end
|
55
|
-
|
56
|
-
Factory.define :role do |f|
|
57
|
-
f.rolename 'administrator'
|
58
|
-
end
|
59
|
-
|
60
|
-
Factory.define :comment do |f|
|
61
|
-
f.body { Factory.next(:description) }
|
62
|
-
f.user {|a| a.association(:user)}
|
63
|
-
f.commentable {|a| a.association(:user)}
|
64
|
-
end
|
65
|
-
|
66
|
-
Factory.define :domain_theme do |f|
|
67
|
-
f.name { Factory.next(:name) }
|
68
|
-
f.uri { Factory.next(:uri) }
|
69
|
-
end
|
70
|
-
|
71
|
-
Factory.define :theme do |f|
|
72
|
-
f.name { Factory.next(:name) }
|
73
|
-
end
|
74
|
-
|
75
|
-
|
File without changes
|
File without changes
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module MuckControllerMacros
|
2
|
-
|
3
|
-
def should_require_login(*args)
|
4
|
-
args = Hash[*args]
|
5
|
-
login_url = args.delete :login_url
|
6
|
-
args.each do |action, verb|
|
7
|
-
should "Require login for '#{action}' action" do
|
8
|
-
if [:put, :delete].include?(verb) # put and delete require an id even if it is a bogus one
|
9
|
-
send(verb, action, :id => 1)
|
10
|
-
else
|
11
|
-
send(verb, action)
|
12
|
-
end
|
13
|
-
assert_redirected_to(login_url)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def should_require_role(role, redirect_url, *actions)
|
19
|
-
actions.each do |action|
|
20
|
-
should "require role for '#{action}' action" do
|
21
|
-
get(action)
|
22
|
-
ensure_flash(/permission/i)
|
23
|
-
assert_response :redirect
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
#from: http://blog.internautdesign.com/2008/9/11/more-on-custom-shoulda-macros-scoping-of-instance-variables
|
29
|
-
def should_not_allow action, object, url= "/login", msg=nil
|
30
|
-
msg ||= "a #{object.class.to_s.downcase}"
|
31
|
-
should "not be able to #{action} #{msg}" do
|
32
|
-
object = eval(object, self.send(:binding), __FILE__, __LINE__)
|
33
|
-
get action, :id => object.id
|
34
|
-
assert_redirected_to url
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def should_allow action, object, msg=nil
|
39
|
-
msg ||= "a #{object.class.to_s.downcase}"
|
40
|
-
should "be able to #{action} #{msg}" do
|
41
|
-
object = eval(object, self.send(:binding), __FILE__, __LINE__)
|
42
|
-
get action, :id => object.id
|
43
|
-
assert_response :success
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
ActionController::TestCase.extend(MuckControllerMacros)
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module ShouldaFormMacros
|
2
|
-
def self.should_have_form(opts)
|
3
|
-
model = self.name.gsub(/ControllerTest$/, '').singularize.downcase
|
4
|
-
model = model[model.rindex('::')+2..model.size] if model.include?('::')
|
5
|
-
http_method, hidden_http_method = form_http_method opts[:method]
|
6
|
-
should "have a #{model} form" do
|
7
|
-
assert_select "form[action=?][method=#{http_method}]", eval(opts[:action]) do
|
8
|
-
if hidden_http_method
|
9
|
-
assert_select "input[type=hidden][name=_method][value=#{hidden_http_method}]"
|
10
|
-
end
|
11
|
-
opts[:fields].each do |attribute, type|
|
12
|
-
attribute = attribute.is_a?(Symbol) ? "#{model}[#{attribute.to_s}]" : attribute
|
13
|
-
assert_select "input[type=#{type.to_s}][name=?]", attribute
|
14
|
-
end
|
15
|
-
assert_select "input[type=submit]"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.form_http_method(http_method)
|
21
|
-
http_method = http_method.nil? ? 'post' : http_method.to_s
|
22
|
-
if http_method == "post" || http_method == "get"
|
23
|
-
return http_method, nil
|
24
|
-
else
|
25
|
-
return "post", http_method
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class ActiveSupport::TestCase
|
31
|
-
extend ShouldaFormMacros
|
32
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module ShouldaModelMacros
|
2
|
-
|
3
|
-
def should_sanitize(*attributes)
|
4
|
-
bad_scripts = [
|
5
|
-
%|';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>|,
|
6
|
-
%|'';!--"<XSS>=&{()}|,
|
7
|
-
%|<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>|,
|
8
|
-
%|<IMG SRC="javascript:alert('XSS');">|,
|
9
|
-
%|<IMG SRC=javascript:alert('XSS')>|,
|
10
|
-
%|<IMG SRC=JaVaScRiPt:alert('XSS')>|,
|
11
|
-
%|<IMG SRC=JaVaScRiPt:alert('XSS')>|,
|
12
|
-
%|<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>|,
|
13
|
-
%|<IMG """><SCRIPT>alert("XSS")</SCRIPT>">|,
|
14
|
-
%|<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>|,
|
15
|
-
%|<A HREF="h
|
16
|
-
tt p://6	6.000146.0x7.147/">XSS</A>|,
|
17
|
-
%|<script>alert('message');</script>| ]
|
18
|
-
|
19
|
-
klass = model_class
|
20
|
-
attributes.each do |attribute|
|
21
|
-
attribute = attribute.to_sym
|
22
|
-
should "white list #{attribute}" do
|
23
|
-
assert object = klass.find(:first), "Can't find first #{klass}"
|
24
|
-
bad_scripts.each do |bad_value|
|
25
|
-
object.send("#{attribute}=", bad_value)
|
26
|
-
object.save
|
27
|
-
clean_value = object.send("#{attribute}")
|
28
|
-
assert !clean_value.include?(bad_value), "#{attribute} is not white listed. #{bad_value} made it through"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def should_accept_nested_attributes_for(*attr_names)
|
35
|
-
klass = self.name.gsub(/Test$/, '').constantize
|
36
|
-
|
37
|
-
context "#{klass}" do
|
38
|
-
attr_names.each do |association_name|
|
39
|
-
should "accept nested attrs for #{association_name}" do
|
40
|
-
assert klass.instance_methods.include?("#{association_name}_attributes="),
|
41
|
-
"#{klass} does not accept nested attributes for #{association_name}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class ActiveSupport::TestCase
|
49
|
-
extend ShouldaModelMacros
|
50
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module ShouldaPaginationMacros
|
2
|
-
# Example:
|
3
|
-
# context "a GET to index logged in as admin" do
|
4
|
-
# setup do
|
5
|
-
# login_as_admin
|
6
|
-
# get :index
|
7
|
-
# end
|
8
|
-
# should_paginate_collection :users
|
9
|
-
# should_display_pagination
|
10
|
-
# end
|
11
|
-
def self.should_paginate_collection(collection_name)
|
12
|
-
should "paginate #{collection_name}" do
|
13
|
-
assert collection = assigns(collection_name),
|
14
|
-
"Controller isn't assigning to @#{collection_name.to_s}."
|
15
|
-
assert_kind_of WillPaginate::Collection, collection,
|
16
|
-
"@#{collection_name.to_s} isn't a WillPaginate collection."
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.should_display_pagination
|
21
|
-
should "display pagination" do
|
22
|
-
assert_select "div.pagination", { :minimum => 1 },
|
23
|
-
"View isn't displaying pagination. Add <%= will_paginate @collection %>."
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Example:
|
28
|
-
# context "a GET to index not logged in as admin" do
|
29
|
-
# setup { get :index }
|
30
|
-
# should_not_paginate_collection :users
|
31
|
-
# should_not_display_pagination
|
32
|
-
# end
|
33
|
-
def self.should_not_paginate_collection(collection_name)
|
34
|
-
should "not paginate #{collection_name}" do
|
35
|
-
assert collection = assigns(collection_name),
|
36
|
-
"Controller isn't assigning to @#{collection_name.to_s}."
|
37
|
-
assert_not_equal WillPaginate::Collection, collection.class,
|
38
|
-
"@#{collection_name.to_s} is a WillPaginate collection."
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.should_not_display_pagination
|
43
|
-
should "not display pagination" do
|
44
|
-
assert_select "div.pagination", { :count => 0 },
|
45
|
-
"View is displaying pagination. Check your logic."
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
class ActiveSupport::TestCase
|
52
|
-
extend ShouldaPaginationMacros
|
53
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module ShouldaPluginMacros
|
2
|
-
|
3
|
-
def self.should_act_as_taggable_on_steroids
|
4
|
-
klass = self.name.gsub(/Test$/, '').constantize
|
5
|
-
|
6
|
-
should "include ActsAsTaggableOnSteroids methods" do
|
7
|
-
assert klass.extended_by.include?(ActiveRecord::Acts::Taggable::ClassMethods)
|
8
|
-
assert klass.extended_by.include?(ActiveRecord::Acts::Taggable::SingletonMethods)
|
9
|
-
assert klass.include?(ActiveRecord::Acts::Taggable::InstanceMethods)
|
10
|
-
end
|
11
|
-
|
12
|
-
should_have_many :taggings, :tags
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
def self.should_act_as_list
|
17
|
-
klass = self.name.gsub(/Test$/, '').constantize
|
18
|
-
|
19
|
-
context "To support acts_as_list" do
|
20
|
-
should_have_db_column('position', :type => :integer)
|
21
|
-
end
|
22
|
-
|
23
|
-
should "include ActsAsList methods" do
|
24
|
-
assert klass.include?(ActiveRecord::Acts::List::InstanceMethods)
|
25
|
-
end
|
26
|
-
|
27
|
-
should_have_instance_methods :acts_as_list_class, :position_column, :scope_condition
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
ActiveSupport::TestCase.extend(ShouldaPluginMacros)
|
33
|
-
Test::Unit::TestCase.extend(ShouldaPluginMacros)
|
34
|
-
ActionController::TestCase.extend(ShouldaPluginMacros)
|