muck-activities 0.1.14 → 0.1.15
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/VERSION +1 -1
- data/app/controllers/muck/activities_controller.rb +1 -3
- data/app/helpers/muck_activity_helper.rb +5 -2
- data/app/views/activities/_status_update.html.erb +2 -2
- data/app/views/activities/_template_filter.html.erb +1 -0
- data/lib/active_record/acts/muck_activity.rb +4 -4
- data/locales/et.yml +1 -1
- data/locales/lt.yml +1 -1
- data/locales/mt.yml +1 -1
- data/locales/sl.yml +1 -1
- data/muck-activities.gemspec +1 -1
- data/test/rails_root/config/environment.rb +1 -1
- data/test/rails_root/test/functional/activities_controller_test.rb +6 -6
- data/test/rails_root/test/functional/default_controller_test.rb +4 -3
- data/test/rails_root/test/unit/activity_test.rb +30 -3
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.15
|
@@ -72,9 +72,7 @@ class Muck::ActivitiesController < ApplicationController
|
|
72
72
|
redirect_back_or_default(@parent)
|
73
73
|
end
|
74
74
|
format.js do
|
75
|
-
render :
|
76
|
-
page_alert(page, message)
|
77
|
-
end
|
75
|
+
render :text => message
|
78
76
|
end
|
79
77
|
format.json do
|
80
78
|
render :json => { :success => false,
|
@@ -59,9 +59,12 @@ module MuckActivityHelper
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# Renders an activity feed filter. Filter items come from the name of the templates used to render the activities.
|
62
|
-
|
62
|
+
# Pass in an array of templates to leave out as the second parameter
|
63
|
+
def activity_filter(activities_object, *dont_include)
|
64
|
+
dont_include = [dont_include] unless dont_include.is_a?(Array)
|
63
65
|
activity_types = activities_object.activities.all(:select => "DISTINCT activities.template")
|
64
|
-
|
66
|
+
filter_types = activity_types.find_all {|activity| !dont_include.include?(activity.template)}
|
67
|
+
render :partial => 'activities/template_filter', :locals => { :activity_types => filter_types, :dont_include => dont_include }
|
65
68
|
end
|
66
69
|
|
67
70
|
def is_current_filter?(template)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<div id="status-update">
|
2
2
|
<%= output_errors(t('muck.users.problem_with_status'), {:class => 'help-box'}, @activity) %>
|
3
3
|
<% remote_form_for(:activity,
|
4
|
-
:url => activities_path(:parent_id => activities_object, :parent_type => activities_object.
|
4
|
+
:url => activities_path(:parent_id => activities_object, :parent_type => activities_object.class, :format => 'js'),
|
5
5
|
:html => { :id => 'status_update_form', :class => 'clear',
|
6
|
-
:action => activities_path(:parent_id => activities_object, :parent_type => activities_object.
|
6
|
+
:action => activities_path(:parent_id => activities_object, :parent_type => activities_object.class) } ) do |f| -%>
|
7
7
|
<div id="progress-bar" style="display:none;">
|
8
8
|
<h3><%= t('muck.activities.updating_status_message') %></h3>
|
9
9
|
<img src="/images/loading.gif" alt="progress bar">
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<ul id="activity-filter">
|
2
2
|
<li class="all-activities <%=no_filter?%>"><a href="<%=all_activities_url%>"><%=t('muck.activities.all_activities')%></a></li>
|
3
3
|
<% activity_types.each do |type| -%>
|
4
|
+
<% continue if dont_include.include?(type) %>
|
4
5
|
<li class="<%= type.template%> <%=is_current_filter?(type.template)%>"><a href="?activity_filter=<%= type.template%>"><%= t("muck.activity_templates.#{type.template}") %></a></li>
|
5
6
|
<% end -%>
|
6
7
|
</ul>
|
@@ -17,13 +17,13 @@ module ActiveRecord
|
|
17
17
|
|
18
18
|
validates_presence_of :source
|
19
19
|
|
20
|
-
named_scope :since, lambda { |time| {:conditions => ["activities.created_at > ?", time] } }
|
21
|
-
named_scope :before, lambda {|time| {:conditions => ["activities.created_at < ?", time] } }
|
20
|
+
named_scope :since, lambda { |time| {:conditions => ["activities.created_at > ?", time || DateTime.now] } }
|
21
|
+
named_scope :before, lambda { |time| {:conditions => ["activities.created_at < ?", time || DateTime.now] } }
|
22
22
|
named_scope :newest, :order => "activities.created_at DESC"
|
23
|
-
named_scope :after, lambda {|id| {:conditions => ["activities.id > ?", id] } }
|
23
|
+
named_scope :after, lambda { |id| {:conditions => ["activities.id > ?", id] } }
|
24
24
|
named_scope :only_public, :conditions => ["activities.is_public = true"]
|
25
25
|
named_scope :filter_by_template, lambda { |template| { :conditions => ["activities.template = ?", template] } unless template.blank? }
|
26
|
-
named_scope :created_by, lambda {|activity_object| {:conditions => ["activities.source_id = ? AND activities.source_type = ?", activity_object.id, activity_object.class.to_s] } }
|
26
|
+
named_scope :created_by, lambda { |activity_object| {:conditions => ["activities.source_id = ? AND activities.source_type = ?", activity_object.id, activity_object.class.to_s] } }
|
27
27
|
named_scope :status_updates, :conditions => ["activities.is_status_update = ?", true]
|
28
28
|
class_eval <<-EOV
|
29
29
|
attr_protected :created_at, :updated_at
|
data/locales/et.yml
CHANGED
@@ -20,7 +20,7 @@ et:
|
|
20
20
|
post: Jagama
|
21
21
|
problem_with_status: "Probleem, muutes oma staatust"
|
22
22
|
status_indicator: "on"
|
23
|
-
status_update_prompt: "Mida
|
23
|
+
status_update_prompt: "Mida sa teed praegu?"
|
24
24
|
template_or_item_required: "Tegevust on vaja malli või objekti kuvada õigesti"
|
25
25
|
time_ago: "{{time_in_words}} Tagasi"
|
26
26
|
update_error: "Oih ... Oli probleem. {{errors}}"
|
data/locales/lt.yml
CHANGED
@@ -11,7 +11,7 @@ lt:
|
|
11
11
|
invite_friends: "Pakviesti draugų"
|
12
12
|
item_could_not_be_removed: "Punktas negali būti pašalinta iš paskutinių veiklos sąrašas."
|
13
13
|
item_created: "Pridėta veikla"
|
14
|
-
item_removed: "Prekė sėkmingai
|
14
|
+
item_removed: "Prekė sėkmingai pašalintas iš paskutinių veiklos sąrašas."
|
15
15
|
joined_status: "{{name}} joined {{application_name}}"
|
16
16
|
make_comment: Komentaras
|
17
17
|
paging_newer: «Naujesni
|
data/locales/mt.yml
CHANGED
@@ -24,7 +24,7 @@ mt:
|
|
24
24
|
template_or_item_required: "Attività teħtieġ template jew oġġett li jintwerew b'mod korrett"
|
25
25
|
time_ago: "{{time_in_words}} Ilu"
|
26
26
|
update_error: "Oops ... Kien hemm problema. {{errors}}"
|
27
|
-
update_status_message: "update
|
27
|
+
update_status_message: "update-istatus tieg ¢ ek!"
|
28
28
|
updating_status_message: "Aġġornament istat tiegħek. Jekk jogħġbok stenna."
|
29
29
|
write_prompt: "Write kumment ..."
|
30
30
|
activity_templates:
|
data/locales/sl.yml
CHANGED
@@ -24,7 +24,7 @@ sl:
|
|
24
24
|
template_or_item_required: "Dejavnost zahteva predlogo ali predmeta na zaslonu pravilno"
|
25
25
|
time_ago: "{{time_in_words}} Ago"
|
26
26
|
update_error: "Ups ... Prišlo je do težave. {{errors}}"
|
27
|
-
update_status_message: "
|
27
|
+
update_status_message: "Posodobite svoje stanje!"
|
28
28
|
updating_status_message: "Posodabljanje vaše stanje. Prosim počakajte."
|
29
29
|
write_prompt: "Napišite komentar ..."
|
30
30
|
activity_templates:
|
data/muck-activities.gemspec
CHANGED
@@ -17,7 +17,7 @@ Rails::Initializer.run do |config|
|
|
17
17
|
config.time_zone = 'UTC'
|
18
18
|
config.gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
|
19
19
|
config.gem "authlogic"
|
20
|
-
config.gem "binarylogic-searchlogic", :lib => 'searchlogic', :source => 'http://gems.github.com'
|
20
|
+
config.gem "binarylogic-searchlogic", :lib => 'searchlogic', :source => 'http://gems.github.com'
|
21
21
|
config.gem "bcrypt-ruby", :lib => "bcrypt"
|
22
22
|
config.gem "collectiveidea-awesome_nested_set", :lib => 'awesome_nested_set', :source => "http://gems.github.com"
|
23
23
|
config.gem 'thoughtbot-paperclip', :lib => 'paperclip', :source => "http://gems.github.com"
|
@@ -19,14 +19,14 @@ class Muck::ActivitiesControllerTest < ActionController::TestCase
|
|
19
19
|
|
20
20
|
context 'on GET to index (js)' do
|
21
21
|
setup do
|
22
|
-
get :index, :parent_type => @user.
|
22
|
+
get :index, :parent_type => @user.class, :parent_id => @user, :format => 'js', :latest_activity_id => @activity.to_param
|
23
23
|
end
|
24
24
|
should_respond_with :success
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'on GET to index (js) no latest activity id' do
|
28
28
|
setup do
|
29
|
-
get :index, :parent_type => @user.
|
29
|
+
get :index, :parent_type => @user.class, :parent_id => @user, :format => 'js', :latest_activity_id => nil
|
30
30
|
end
|
31
31
|
should_respond_with :success
|
32
32
|
end
|
@@ -34,7 +34,7 @@ class Muck::ActivitiesControllerTest < ActionController::TestCase
|
|
34
34
|
|
35
35
|
context 'fail on POST to create (json)' do
|
36
36
|
setup do
|
37
|
-
post :create, :activity => { :content => 'test activity' }, :parent_type => @user.
|
37
|
+
post :create, :activity => { :content => 'test activity' }, :parent_type => @user.class.to_s, :parent_id => @user, :format => 'json'
|
38
38
|
end
|
39
39
|
should_respond_with :success
|
40
40
|
should_not_set_the_flash
|
@@ -48,7 +48,7 @@ class Muck::ActivitiesControllerTest < ActionController::TestCase
|
|
48
48
|
context 'on POST to create (json)' do
|
49
49
|
setup do
|
50
50
|
@activity_content = 'test content for my new activity'
|
51
|
-
post :create, :activity => { :content => @activity_content, :template => 'status_update' }, :parent_type => @user.
|
51
|
+
post :create, :activity => { :content => @activity_content, :template => 'status_update' }, :parent_type => @user.class, :parent_id => @user, :format => 'json'
|
52
52
|
end
|
53
53
|
should_respond_with :success
|
54
54
|
should_not_set_the_flash
|
@@ -63,7 +63,7 @@ class Muck::ActivitiesControllerTest < ActionController::TestCase
|
|
63
63
|
|
64
64
|
context 'on POST to create (js)' do
|
65
65
|
setup do
|
66
|
-
post :create, :activity => { :content => 'test activity' }, :parent_type => @user.
|
66
|
+
post :create, :activity => { :content => 'test activity' }, :parent_type => @user.class, :parent_id => @user, :format => 'js'
|
67
67
|
end
|
68
68
|
should_respond_with :success
|
69
69
|
should_not_set_the_flash
|
@@ -71,7 +71,7 @@ class Muck::ActivitiesControllerTest < ActionController::TestCase
|
|
71
71
|
|
72
72
|
context 'on POST to create' do
|
73
73
|
setup do
|
74
|
-
post :create, :activity => { :content => 'test activity' }, :parent_type => @user.
|
74
|
+
post :create, :activity => { :content => 'test activity' }, :parent_type => @user.class, :parent_id => @user
|
75
75
|
end
|
76
76
|
should_redirect_to('show user page (user dashboard)') { @user }
|
77
77
|
end
|
@@ -7,14 +7,15 @@ class DefaultControllerTest < ActionController::TestCase
|
|
7
7
|
context "default controller" do
|
8
8
|
setup do
|
9
9
|
activate_authlogic
|
10
|
-
@user = Factory(:user)
|
10
|
+
@user = Factory(:user)
|
11
11
|
login_as @user
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'on GET to index' do
|
15
|
-
#
|
16
|
-
#
|
15
|
+
# The default view calls the helpers. This isn't a great test but
|
16
|
+
# it will make sure they don't blow up
|
17
17
|
setup do
|
18
|
+
@user.activities << Factory(:activity, :template => 'status_update')
|
18
19
|
@user.activities << Factory(:activity, :template => 'status_update')
|
19
20
|
get :index
|
20
21
|
end
|
@@ -11,15 +11,42 @@ class ActivityTest < ActiveSupport::TestCase
|
|
11
11
|
should_have_many :activity_feeds
|
12
12
|
should_have_many :comments
|
13
13
|
|
14
|
-
should_have_named_scope :since
|
15
|
-
should_have_named_scope :before
|
16
14
|
should_have_named_scope :newest
|
17
15
|
should_have_named_scope :only_public
|
18
|
-
should_have_named_scope :filter_by_template
|
19
16
|
should_have_named_scope :status_updates
|
20
17
|
|
21
18
|
end
|
22
19
|
|
20
|
+
context "named scopes" do
|
21
|
+
setup do
|
22
|
+
@old_activity = Factory(:activity, :created_at => 6.weeks.ago)
|
23
|
+
@new_activity = Factory(:activity)
|
24
|
+
@status_activity = Factory(:activity, :template => 'status')
|
25
|
+
@other_activity = Factory(:activity, :template => 'other')
|
26
|
+
end
|
27
|
+
context "before" do
|
28
|
+
should "only find old activity" do
|
29
|
+
activities = Activity.before(1.week.ago)
|
30
|
+
assert activities.include?(@old_activity), "since didn't find older activity"
|
31
|
+
assert !activities.include?(@new_activity), "since found new activity"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
context "since" do
|
35
|
+
should "only find new activity" do
|
36
|
+
activities = Activity.since(1.week.ago)
|
37
|
+
assert !activities.include?(@old_activity), "since found older activity"
|
38
|
+
assert activities.include?(@new_activity), "since didn't find new activity"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
context "filter_by_template" do
|
42
|
+
should "only find status template" do
|
43
|
+
activities = Activity.filter_by_template('status')
|
44
|
+
assert activities.include?(@status_activity), "since didn't find status activity"
|
45
|
+
assert !activities.include?(@other_activity), "since found other activity"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
23
50
|
should "require template or item" do
|
24
51
|
activity = Factory.build(:activity, :template => nil, :item => nil)
|
25
52
|
assert !activity.valid?
|