muck-activities 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +69 -0
  3. data/Rakefile +78 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/muck/activities_controller.rb +152 -0
  6. data/app/helpers/muck_activity_helper.rb +67 -0
  7. data/app/models/activity.rb +62 -0
  8. data/app/models/activity_feed.rb +16 -0
  9. data/app/views/activities/_activity_feed.html.erb +18 -0
  10. data/app/views/activities/_cached_activities.html.erb +8 -0
  11. data/app/views/activities/_comment.html.erb +6 -0
  12. data/app/views/activities/_comments.html.erb +7 -0
  13. data/app/views/activities/_current_status.html.erb +14 -0
  14. data/app/views/activities/_current_status_wrapper.html.erb +4 -0
  15. data/app/views/activities/_delete.html.erb +11 -0
  16. data/app/views/activities/_status_update.html.erb +35 -0
  17. data/app/views/activities/_template_filter.html.erb +6 -0
  18. data/app/views/activity_templates/_status_update.html.erb +12 -0
  19. data/config/muck_activities_routes.rb +3 -0
  20. data/db/migrate/20090402033319_add_muck_activities.rb +36 -0
  21. data/install.rb +1 -0
  22. data/lib/muck_activities/initialize_routes.rb +8 -0
  23. data/lib/muck_activities/tasks.rb +28 -0
  24. data/lib/muck_activities.rb +76 -0
  25. data/locales/ar.yml +24 -0
  26. data/locales/bg.yml +24 -0
  27. data/locales/ca.yml +24 -0
  28. data/locales/cs.yml +24 -0
  29. data/locales/da.yml +24 -0
  30. data/locales/de.yml +24 -0
  31. data/locales/el.yml +24 -0
  32. data/locales/en.yml +25 -0
  33. data/locales/es.yml +24 -0
  34. data/locales/fr.yml +24 -0
  35. data/locales/it.yml +24 -0
  36. data/locales/iw.yml +24 -0
  37. data/locales/ja.yml +24 -0
  38. data/locales/ko.yml +24 -0
  39. data/locales/lt.yml +24 -0
  40. data/locales/lv.yml +24 -0
  41. data/locales/nl.yml +24 -0
  42. data/locales/no.yml +25 -0
  43. data/locales/pl.yml +24 -0
  44. data/locales/pt.yml +24 -0
  45. data/locales/ro.yml +24 -0
  46. data/locales/ru.yml +24 -0
  47. data/locales/sk.yml +24 -0
  48. data/locales/sl.yml +24 -0
  49. data/locales/sr.yml +24 -0
  50. data/locales/sv.yml +24 -0
  51. data/locales/tl.yml +24 -0
  52. data/locales/uk.yml +24 -0
  53. data/locales/vi.yml +24 -0
  54. data/locales/zh-CN.yml +24 -0
  55. data/locales/zh-TW.yml +24 -0
  56. data/locales/zh.yml +24 -0
  57. data/public/images/loading.gif +0 -0
  58. data/public/javascripts/muck_activities.js +65 -0
  59. data/rails/init.rb +4 -0
  60. data/rdoc/classes/ActionController/Routing/RouteSet.html +148 -0
  61. data/rdoc/classes/ActionController/Routing.html +107 -0
  62. data/rdoc/classes/ActionController.html +107 -0
  63. data/rdoc/classes/MuckActivity/ActMethods.html +189 -0
  64. data/rdoc/classes/MuckActivity/InstanceMethods.html +244 -0
  65. data/rdoc/classes/MuckActivity/Tasks.html +146 -0
  66. data/rdoc/created.rid +1 -0
  67. data/rdoc/files/README_rdoc.html +212 -0
  68. data/rdoc/files/lib/muck_activity/initialize_routes_rb.html +101 -0
  69. data/rdoc/files/lib/muck_activity/tasks_rb.html +110 -0
  70. data/rdoc/files/lib/muck_activity_rb.html +108 -0
  71. data/rdoc/fr_class_index.html +32 -0
  72. data/rdoc/fr_file_index.html +30 -0
  73. data/rdoc/fr_method_index.html +33 -0
  74. data/rdoc/index.html +24 -0
  75. data/rdoc/rdoc-style.css +208 -0
  76. data/tasks/muck_activity_tasks.rake +1 -0
  77. data/test/factories.rb +41 -0
  78. data/test/functional/activities_controller_test.rb +64 -0
  79. data/test/shoulda_macros/controller.rb +43 -0
  80. data/test/test_helper.rb +38 -0
  81. data/test/unit/activity_feed_test.rb +5 -0
  82. data/test/unit/activity_test.rb +57 -0
  83. data/uninstall.rb +1 -0
  84. metadata +169 -0
@@ -0,0 +1,32 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Classes
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Classes</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Classes</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/ActionController.html">ActionController</a><br />
24
+ <a href="classes/ActionController/Routing.html">ActionController::Routing</a><br />
25
+ <a href="classes/ActionController/Routing/RouteSet.html">ActionController::Routing::RouteSet</a><br />
26
+ <a href="classes/MuckActivity/ActMethods.html">MuckActivity::ActMethods</a><br />
27
+ <a href="classes/MuckActivity/InstanceMethods.html">MuckActivity::InstanceMethods</a><br />
28
+ <a href="classes/MuckActivity/Tasks.html">MuckActivity::Tasks</a><br />
29
+ </div>
30
+ </div>
31
+ </body>
32
+ </html>
@@ -0,0 +1,30 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Files
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Files</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Files</h1>
22
+ <div id="index-entries">
23
+ <a href="files/README_rdoc.html">README.rdoc</a><br />
24
+ <a href="files/lib/muck_activity_rb.html">lib/muck_activity.rb</a><br />
25
+ <a href="files/lib/muck_activity/initialize_routes_rb.html">lib/muck_activity/initialize_routes.rb</a><br />
26
+ <a href="files/lib/muck_activity/tasks_rb.html">lib/muck_activity/tasks.rb</a><br />
27
+ </div>
28
+ </div>
29
+ </body>
30
+ </html>
@@ -0,0 +1,33 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Methods
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Methods</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Methods</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/MuckActivity/ActMethods.html#M000003">acts_as_activity_source (MuckActivity::ActMethods)</a><br />
24
+ <a href="classes/MuckActivity/InstanceMethods.html#M000004">add_activity (MuckActivity::InstanceMethods)</a><br />
25
+ <a href="classes/MuckActivity/InstanceMethods.html#M000006">can_view? (MuckActivity::InstanceMethods)</a><br />
26
+ <a href="classes/MuckActivity/ActMethods.html#M000002">has_activities (MuckActivity::ActMethods)</a><br />
27
+ <a href="classes/ActionController/Routing/RouteSet.html#M000001">load_routes_with_muck_activity! (ActionController::Routing::RouteSet)</a><br />
28
+ <a href="classes/MuckActivity/Tasks.html#M000007">new (MuckActivity::Tasks)</a><br />
29
+ <a href="classes/MuckActivity/InstanceMethods.html#M000005">status (MuckActivity::InstanceMethods)</a><br />
30
+ </div>
31
+ </div>
32
+ </body>
33
+ </html>
data/rdoc/index.html ADDED
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ MuckActivity
9
+
10
+ -->
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
+ <head>
13
+ <title>MuckActivity</title>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
+ </head>
16
+ <frameset rows="20%, 80%">
17
+ <frameset cols="25%,35%,45%">
18
+ <frame src="fr_file_index.html" title="Files" name="Files" />
19
+ <frame src="fr_class_index.html" name="Classes" />
20
+ <frame src="fr_method_index.html" name="Methods" />
21
+ </frameset>
22
+ <frame src="files/README_rdoc.html" name="docwin" />
23
+ </frameset>
24
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), '/../lib/muck_activities/tasks')
data/test/factories.rb ADDED
@@ -0,0 +1,41 @@
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 :abbr do |n|
14
+ "abbr#{n}"
15
+ end
16
+
17
+ Factory.sequence :description do |n|
18
+ "This is the description: #{n}"
19
+ end
20
+
21
+ Factory.define :user do |f|
22
+ f.login { Factory.next(:login) }
23
+ f.email { Factory.next(:email) }
24
+ f.password 'inquire_pass'
25
+ f.password_confirmation 'inquire_pass'
26
+ f.first_name 'test'
27
+ f.last_name 'guy'
28
+ f.terms_of_service true
29
+ f.activated_at DateTime.now
30
+ end
31
+
32
+ Factory.define :activity do |f|
33
+ f.item {|a| a.association(:user)}
34
+ f.template ''
35
+ f.source {|a| a.association(:user)}
36
+ f.content ''
37
+ f.title ''
38
+ f.is_status_update false
39
+ f.is_public true
40
+ f.created_at DateTime.now
41
+ end
@@ -0,0 +1,64 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class Muck::ActivitiesControllerTest < ActionController::TestCase
4
+
5
+ tests Muck::ActivitiesController
6
+
7
+ context "activities controller" do
8
+ setup do
9
+ activate_authlogic
10
+ @user = Factory(:user)
11
+ login_as @user
12
+ end
13
+
14
+ context 'on GET to index (js)' do
15
+ setup do
16
+ @activity = Factory(:activity)
17
+ get :index, :parent_type => @user.type, :parent_id => @user, :format => 'js', :latest_activity_id => @activity.to_param
18
+ end
19
+ should_respond_with :success
20
+ end
21
+
22
+ context 'on GET to index (js) no latest activity id' do
23
+ setup do
24
+ get :index, :parent_type => @user.type, :parent_id => @user, :format => 'js', :latest_activity_id => nil
25
+ end
26
+ should_respond_with :success
27
+ end
28
+
29
+ context 'on POST to create (js)' do
30
+ setup do
31
+ post :create, :activity => { :content => 'test activity' }, :parent_type => @user.type, :parent_id => @user, :format => 'js'
32
+ end
33
+ should_respond_with :success
34
+ should_not_set_the_flash
35
+ end
36
+
37
+ context 'on POST to create' do
38
+ setup do
39
+ post :create, :activity => { :content => 'test activity' }, :parent_type => @user.type, :parent_id => @user
40
+ end
41
+ should_redirect_to('show user page (user dashboard)') { @user }
42
+ end
43
+
44
+ context 'on DELETE to destroy' do
45
+ setup do
46
+ @activity = Factory(:activity, :source => @user)
47
+ delete :destroy, :id => @activity.id
48
+ end
49
+ should_respond_with :redirect
50
+ should_set_the_flash_to(I18n.t("muck.activities.item_removed"))
51
+ end
52
+
53
+ context 'on DELETE to destroy (js)' do
54
+ setup do
55
+ @activity = Factory(:activity, :source => @user)
56
+ delete :destroy, :id => @activity.id, :format => 'js'
57
+ end
58
+ should_respond_with :success
59
+ should_not_set_the_flash
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,43 @@
1
+ ActiveSupport::TestCase.class_eval do
2
+
3
+ def self.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
+ send(verb, action)
9
+ assert_redirected_to(login_url)
10
+ end
11
+ end
12
+ end
13
+
14
+ def self.should_require_role(role, redirect_url, *actions)
15
+ actions.each do |action|
16
+ should "require role for '#{action}' action" do
17
+ get(action)
18
+ ensure_flash(/permission/i)
19
+ assert_response :redirect
20
+ end
21
+ end
22
+ end
23
+
24
+ #from: http://blog.internautdesign.com/2008/9/11/more-on-custom-shoulda-macros-scoping-of-instance-variables
25
+ def self.should_not_allow action, object, url= "/login", msg=nil
26
+ msg ||= "a #{object.class.to_s.downcase}"
27
+ should "not be able to #{action} #{msg}" do
28
+ object = eval(object, self.send(:binding), __FILE__, __LINE__)
29
+ get action, :id => object.id
30
+ assert_redirected_to url
31
+ end
32
+ end
33
+
34
+ def self.should_allow action, object, msg=nil
35
+ msg ||= "a #{object.class.to_s.downcase}"
36
+ should "be able to #{action} #{msg}" do
37
+ object = eval(object, self.send(:binding), __FILE__, __LINE__)
38
+ get action, :id => object.id
39
+ assert_response :success
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,38 @@
1
+ $:.reject! { |e| e.include? 'TextMate' }
2
+ ENV["RAILS_ENV"] = "test"
3
+ #require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
4
+ require 'rubygems'
5
+ require 'factory_girl'
6
+ require 'ruby-debug'
7
+ require 'mocha'
8
+ require 'authlogic'
9
+ require 'authlogic/test_case'
10
+ require 'active_record'
11
+ require 'redgreen' rescue LoadError
12
+ require File.expand_path(File.dirname(__FILE__) + '/factories')
13
+ require File.join(File.dirname(__FILE__), 'shoulda_macros', 'controller')
14
+ class ActiveSupport::TestCase
15
+ self.use_transactional_fixtures = true
16
+ self.use_instantiated_fixtures = false
17
+
18
+ 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
+ end
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ActivityFeedTest < ActiveSupport::TestCase
4
+
5
+ end
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ActivityTest < ActiveSupport::TestCase
4
+
5
+ context 'An Activity' do
6
+
7
+ should_validate_presence_of :source
8
+
9
+ should_belong_to :item
10
+ should_belong_to :source
11
+ should_have_many :activity_feeds
12
+
13
+ should_have_named_scope :since
14
+ should_have_named_scope :before
15
+ should_have_named_scope :recent
16
+ should_have_named_scope :only_public
17
+ should_have_named_scope :filter_by_template
18
+ end
19
+
20
+ should "require template or item" do
21
+ activity = Factory.build(:activity, :template => nil, :item => nil)
22
+ assert !activity.valid?
23
+ end
24
+
25
+ should "get the partial from the template" do
26
+ template = 'status_update'
27
+ activity = Factory(:activity, :template => template, :item => nil)
28
+ assert activity.partial == template, "The activity partial was not set to the specified template"
29
+ end
30
+
31
+ should "get the partial from the item" do
32
+ user = Factory(:user)
33
+ activity = Factory(:activity, :item => user, :template => nil)
34
+ assert activity.partial == user.class.name.underscore
35
+ end
36
+
37
+ should "be able to edit the activity" do
38
+ user = Factory(:user)
39
+ activity = Factory(:activity, :source => user)
40
+ assert activity.can_edit?(user)
41
+ end
42
+
43
+ should "not be able to edit the activity" do
44
+ user = Factory(:user)
45
+ activity = Factory(:activity)
46
+ assert !activity.can_edit?(user)
47
+ end
48
+
49
+ should "filter the activities by template" do
50
+ @template_name = 'test_template'
51
+ user = Factory(:user)
52
+ activity = Factory(:activity, :source => user, :template => @template_name)
53
+ user.activities << activity
54
+ assert user.activities.filter_by_template(@template_name).include?(activity)
55
+ end
56
+
57
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here