social_stream 0.25.1 → 0.25.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/base/app/controllers/conversations_controller.rb +15 -10
  2. data/base/app/controllers/followers_controller.rb +4 -9
  3. data/base/app/helpers/permissions_helper.rb +4 -0
  4. data/base/app/models/activity_action.rb +4 -0
  5. data/base/app/models/activity_object.rb +9 -0
  6. data/base/app/models/actor.rb +19 -0
  7. data/base/app/models/group.rb +5 -0
  8. data/base/app/models/relation/single.rb +2 -1
  9. data/base/app/models/user.rb +1 -1
  10. data/base/app/views/conversations/destroy.js.erb +2 -0
  11. data/base/app/views/followers/index.html.erb +26 -5
  12. data/base/app/views/permissions/_index.html.erb +7 -2
  13. data/base/app/views/profiles/update.js.erb +4 -9
  14. data/base/app/views/relation/customs/_list.html.erb +4 -0
  15. data/base/config/locales/en.yml +4 -0
  16. data/base/config/locales/es.yml +5 -1
  17. data/base/config/routes.rb +31 -32
  18. data/base/lib/generators/social_stream/base/templates/initializer.rb +5 -1
  19. data/base/lib/social_stream-base.rb +12 -1
  20. data/base/lib/social_stream/base/version.rb +1 -1
  21. data/base/lib/social_stream/models/object.rb +5 -0
  22. data/base/lib/social_stream/models/supertype.rb +1 -1
  23. data/base/lib/social_stream/routing/constraints/custom.rb +11 -0
  24. data/base/lib/social_stream/routing/constraints/follow.rb +11 -0
  25. data/base/lib/social_stream/routing/constraints/resque.rb +11 -0
  26. data/base/spec/controllers/followers_controller_spec.rb +37 -0
  27. data/base/spec/controllers/posts_controller_spec.rb +196 -163
  28. data/base/spec/dummy/config/initializers/social_stream.rb +5 -1
  29. data/base/spec/factories/tie.rb +4 -0
  30. data/base/spec/integration/resque_access_spec.rb +30 -0
  31. data/base/spec/models/post_spec.rb +66 -17
  32. data/documents/app/controllers/documents_controller.rb +3 -10
  33. data/documents/app/views/common_documents/_headers.html.erb +1 -1
  34. data/documents/lib/social_stream/documents/version.rb +1 -1
  35. data/documents/lib/tasks/db/populate_documents.rake +36 -0
  36. data/documents/social_stream-documents.gemspec +1 -1
  37. data/lib/social_stream/version.rb +1 -1
  38. data/social_stream.gemspec +2 -2
  39. metadata +35 -28
@@ -27,7 +27,11 @@ SocialStream.setup do |config|
27
27
  # :follow - user just follow other users, like Twitter
28
28
  #
29
29
  # config.relation_model = :custom
30
-
30
+
31
+ # Expose resque interface to manage background tasks at /resque
32
+ #
33
+ # config.resque_access = true
34
+
31
35
  # Quick search (header) and Extended search models and its order. Remember to create
32
36
  # the indexes with thinking-sphinx if you are using customized models.
33
37
  #
@@ -20,6 +20,10 @@ Factory.define :reject, :parent => :tie do |t|
20
20
  t.after_build { |u| u.relation = Relation::Reject.instance }
21
21
  end
22
22
 
23
+ Factory.define :follow, :parent => :tie do |t|
24
+ t.after_build { |u| u.relation = Relation::Follow.instance }
25
+ end
26
+
23
27
  # Group ties
24
28
  Factory.define :g2u_tie, :parent => :tie do |t|
25
29
  t.contact { |c| Factory(:group_contact) }
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ResqueAccess" do
4
+ context "with config enabled" do
5
+ before do
6
+ SocialStream.resque_access = true
7
+ end
8
+
9
+ it "should be success" do
10
+ get '/resque/overview'
11
+
12
+ response.should be_success
13
+ end
14
+ end
15
+
16
+ context "with config disabled" do
17
+ before do
18
+ SocialStream.resque_access = false
19
+ end
20
+
21
+ it "should be success" do
22
+ begin
23
+ get '/resque/overview'
24
+ assert false
25
+ rescue ActionController::RoutingError
26
+ assert true
27
+ end
28
+ end
29
+ end
30
+ end
@@ -32,32 +32,81 @@ describe Post do
32
32
  end
33
33
 
34
34
  context "without relations" do
35
- it "should allow create to friend" do
36
- tie = Factory(:friend)
35
+ before :all do
36
+ @ss_relation_model = SocialStream.relation_model
37
+ end
38
+
39
+ after :all do
40
+ SocialStream.relation_model = @ss_relation_model
41
+ end
42
+
43
+ context "in follow relation model" do
44
+ before do
45
+ SocialStream.relation_model = :follow
46
+ end
47
+
48
+ it "should allow create to follower" do
49
+ tie = Factory(:follow)
50
+
51
+ post = Post.new :text => "testing",
52
+ :author_id => tie.receiver.id,
53
+ :owner_id => tie.sender.id,
54
+ :user_author_id => tie.receiver.id
55
+
56
+ assert post.build_post_activity.allow? tie.receiver_subject, 'create'
57
+
58
+ ability = Ability.new(tie.receiver_subject)
59
+
60
+ ability.should be_able_to(:create, post)
61
+ end
37
62
 
38
- post = Post.new :text => "testing",
39
- :author_id => tie.receiver.id,
40
- :owner_id => tie.sender.id,
41
- :user_author_id => tie.receiver.id
63
+ it "should fill relation" do
64
+ tie = Factory(:follow)
42
65
 
43
- assert post.build_post_activity.allow? tie.receiver_subject, 'create'
66
+ post = Post.new :text => "testing",
67
+ :author_id => tie.receiver.id,
68
+ :owner_id => tie.sender.id,
69
+ :user_author_id => tie.receiver.id
44
70
 
45
- ability = Ability.new(tie.receiver_subject)
71
+ post.save!
72
+
73
+ post.post_activity.relations.should include(Relation::Public.instance)
74
+ end
46
75
 
47
- ability.should be_able_to(:create, post)
48
76
  end
49
77
 
50
- it "should fill relation" do
51
- tie = Factory(:friend)
78
+ context "in custom relation model" do
79
+ before do
80
+ SocialStream.relation_model = :custom
81
+ end
82
+
83
+ it "should allow create to friend" do
84
+ tie = Factory(:friend)
85
+
86
+ post = Post.new :text => "testing",
87
+ :author_id => tie.receiver.id,
88
+ :owner_id => tie.sender.id,
89
+ :user_author_id => tie.receiver.id
52
90
 
53
- post = Post.new :text => "testing",
54
- :author_id => tie.receiver.id,
55
- :owner_id => tie.sender.id,
56
- :user_author_id => tie.receiver.id
91
+ assert post.build_post_activity.allow? tie.receiver_subject, 'create'
57
92
 
58
- post.save!
93
+ ability = Ability.new(tie.receiver_subject)
59
94
 
60
- post.post_activity.relations.should include(tie.relation)
95
+ ability.should be_able_to(:create, post)
96
+ end
97
+
98
+ it "should fill relation" do
99
+ tie = Factory(:friend)
100
+
101
+ post = Post.new :text => "testing",
102
+ :author_id => tie.receiver.id,
103
+ :owner_id => tie.sender.id,
104
+ :user_author_id => tie.receiver.id
105
+
106
+ post.save!
107
+
108
+ post.post_activity.relations.should include(tie.relation)
109
+ end
61
110
  end
62
111
  end
63
112
 
@@ -7,7 +7,6 @@ class DocumentsController < ApplicationController
7
7
  before_filter :profile_subject!, :only => :index
8
8
 
9
9
  PER_PAGE=20
10
- SEND_FILE_METHOD = :default
11
10
 
12
11
  def index
13
12
  super do |format|
@@ -60,12 +59,6 @@ class DocumentsController < ApplicationController
60
59
  :type => @document.file_content_type
61
60
  }
62
61
 
63
- # Ask Victor about the rationale of this:
64
- case SEND_FILE_METHOD
65
- when :apache then send_file_options[:x_sendfile] = true
66
- when :nginx then head(:x_accel_redirect => path.gsub(Rails.root, ''))
67
- end
68
-
69
62
  send_file(path, send_file_options)
70
63
  end
71
64
 
@@ -75,8 +68,8 @@ class DocumentsController < ApplicationController
75
68
  @activities = profile_subject.wall(:profile,
76
69
  :for => current_subject,
77
70
  :object_type => Array(self.class.index_object_type))
78
- if params[:query].present?
79
- @activities = @activities.joins(:activity_objects => :document).where('documents.title LIKE ?', get_search_query)
71
+ if params[:q].present?
72
+ @activities = @activities.joins(:activity_objects).where('activity_objects.title LIKE ? OR activity_objects.description LIKE ?', get_search_query, get_search_query)
80
73
  end
81
74
  @activities = @activities.page(params[:page]).per(PER_PAGE)
82
75
  end
@@ -89,7 +82,7 @@ class DocumentsController < ApplicationController
89
82
 
90
83
  def get_search_query
91
84
  search_query = ""
92
- param = strip_tags(params[:query]) || ""
85
+ param = strip_tags(params[:q]) || ""
93
86
  bare_query = param unless bare_query.html_safe?
94
87
  search_query_words = bare_query.strip.split
95
88
  search_query_words.each_index do |i|
@@ -54,7 +54,7 @@ $(document).ready(function() {
54
54
  $("#documents_grid").html("<center><%= escape_javascript(image_tag('loading.gif', :class => :loading)) %></center>");
55
55
  $.ajax({
56
56
  type : "GET",
57
- url : "<%= polymorphic_url([current_subject, Document.new]) %>?query=" + searchstring + "&no_layout=true",
57
+ url : "<%= polymorphic_url([current_subject, Document.new]) %>?q=" + searchstring + "&no_layout=true",
58
58
  success : function(html) {
59
59
  if ($("#repository_filter_input").val()==searchstring){ //Only show if input value is still the same
60
60
  $("#documents_grid").html(html);
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Documents
3
- VERSION = "0.13.1".freeze
3
+ VERSION = "0.13.2".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,36 @@
1
+ namespace :db do
2
+ namespace :populate do
3
+
4
+ desc "Create populate data with documents"
5
+ task :create => :create_documents
6
+
7
+ desc "Add documents to populate data"
8
+ task :create_documents => :read_environment do
9
+ puts 'Documents population'
10
+ docs_start = Time.now
11
+
12
+ doc_files = Forgery::Extensions::Array.new(Dir.glob(File.join(Rails.root, 'lib', 'documents', "*")))
13
+
14
+ 50.times do
15
+ updated = Time.at(rand(Time.now.to_i))
16
+ author = Actor.all[rand(Actor.all.size)]
17
+ owner = author
18
+ user_author = ( author.subject_type == "User" ? author : author.user_author )
19
+
20
+ d = Document.create! :file => File.open(doc_files.random, "r"),
21
+ :title => Forgery::LoremIpsum.words(1+rand(4),:random => true),
22
+ :created_at => Time.at(rand(updated.to_i)),
23
+ :updated_at => updated,
24
+ :author_id => author.id,
25
+ :owner_id => owner.id,
26
+ :user_author_id => user_author.id,
27
+ :_relation_ids => [Relation::Public.instance.id]
28
+ d.save!
29
+ end
30
+
31
+ docs_end = Time.now
32
+ puts ' -> ' + (docs_end - docs_start).round(4).to_s + 's'
33
+ end
34
+ end
35
+ end
36
+
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.19.1')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.19.2')
16
16
  s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
17
17
  s.add_runtime_dependency('paperclip','= 2.4.5')
18
18
  s.add_runtime_dependency('delayed_paperclip','2.4.5.1')
@@ -1,3 +1,3 @@
1
1
  module SocialStream
2
- VERSION = "0.25.1".freeze
2
+ VERSION = "0.25.2".freeze
3
3
  end
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.files = `git ls-files`.split("\n")
12
12
 
13
13
  # Gem dependencies
14
- s.add_runtime_dependency('social_stream-base', '~> 0.19.1')
15
- s.add_runtime_dependency('social_stream-documents', '~> 0.13.1')
14
+ s.add_runtime_dependency('social_stream-base', '~> 0.19.2')
15
+ s.add_runtime_dependency('social_stream-documents', '~> 0.13.2')
16
16
  s.add_runtime_dependency('social_stream-events', '~> 0.11.0')
17
17
  s.add_runtime_dependency('social_stream-linkser', '~> 0.9.0')
18
18
  s.add_runtime_dependency('social_stream-presence', '~> 0.12.0')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.1
4
+ version: 0.25.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,33 +10,33 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-04-03 00:00:00.000000000Z
13
+ date: 2012-04-11 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: social_stream-base
17
- requirement: &82780440 !ruby/object:Gem::Requirement
17
+ requirement: &80624950 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.19.1
22
+ version: 0.19.2
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *82780440
25
+ version_requirements: *80624950
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: social_stream-documents
28
- requirement: &82778310 !ruby/object:Gem::Requirement
28
+ requirement: &80612120 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.13.1
33
+ version: 0.13.2
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *82778310
36
+ version_requirements: *80612120
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: social_stream-events
39
- requirement: &82775280 !ruby/object:Gem::Requirement
39
+ requirement: &80607490 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.11.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *82775280
47
+ version_requirements: *80607490
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: social_stream-linkser
50
- requirement: &82774270 !ruby/object:Gem::Requirement
50
+ requirement: &80586880 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.9.0
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *82774270
58
+ version_requirements: *80586880
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: social_stream-presence
61
- requirement: &82772290 !ruby/object:Gem::Requirement
61
+ requirement: &80553820 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 0.12.0
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *82772290
69
+ version_requirements: *80553820
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: capybara
72
- requirement: &82769670 !ruby/object:Gem::Requirement
72
+ requirement: &80545390 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 0.3.9
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *82769670
80
+ version_requirements: *80545390
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: sqlite3
83
- requirement: &82767730 !ruby/object:Gem::Requirement
83
+ requirement: &80544550 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *82767730
91
+ version_requirements: *80544550
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: ruby-debug19
94
- requirement: &82750030 !ruby/object:Gem::Requirement
94
+ requirement: &80543960 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *82750030
102
+ version_requirements: *80543960
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rspec-rails
105
- requirement: &82747580 !ruby/object:Gem::Requirement
105
+ requirement: &80543340 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ~>
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: 2.8.0
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *82747580
113
+ version_requirements: *80543340
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: factory_girl
116
- requirement: &82746360 !ruby/object:Gem::Requirement
116
+ requirement: &80542510 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ~>
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: 1.3.2
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *82746360
124
+ version_requirements: *80542510
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: forgery
127
- requirement: &82736970 !ruby/object:Gem::Requirement
127
+ requirement: &80540950 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ~>
@@ -132,10 +132,10 @@ dependencies:
132
132
  version: 0.4.2
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *82736970
135
+ version_requirements: *80540950
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: ci_reporter
138
- requirement: &82735660 !ruby/object:Gem::Requirement
138
+ requirement: &80537790 !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
141
  - - ~>
@@ -143,7 +143,7 @@ dependencies:
143
143
  version: 1.6.4
144
144
  type: :development
145
145
  prerelease: false
146
- version_requirements: *82735660
146
+ version_requirements: *80537790
147
147
  description: Social Stream is a Ruby on Rails engine for building social network websites.
148
148
  It supports contacts, posts, file uploads, private messages and many more.
149
149
  email:
@@ -514,6 +514,7 @@ files:
514
514
  - base/app/views/conversations/_conversations.html.erb
515
515
  - base/app/views/conversations/_index.html.erb
516
516
  - base/app/views/conversations/_show.html.erb
517
+ - base/app/views/conversations/destroy.js.erb
517
518
  - base/app/views/conversations/edit.html.erb
518
519
  - base/app/views/conversations/index.html.erb
519
520
  - base/app/views/conversations/index.js.erb
@@ -703,6 +704,9 @@ files:
703
704
  - base/lib/social_stream/models/subtype.rb
704
705
  - base/lib/social_stream/models/supertype.rb
705
706
  - base/lib/social_stream/populate.rb
707
+ - base/lib/social_stream/routing/constraints/custom.rb
708
+ - base/lib/social_stream/routing/constraints/follow.rb
709
+ - base/lib/social_stream/routing/constraints/resque.rb
706
710
  - base/lib/social_stream/test_helpers.rb
707
711
  - base/lib/social_stream/test_helpers/controllers.rb
708
712
  - base/lib/social_stream/views/list.rb
@@ -714,6 +718,7 @@ files:
714
718
  - base/social_stream-base.gemspec
715
719
  - base/spec/controllers/comments_controller_spec.rb
716
720
  - base/spec/controllers/contacts_controller_spec.rb
721
+ - base/spec/controllers/followers_controller_spec.rb
717
722
  - base/spec/controllers/frontpage_controller_spec.rb
718
723
  - base/spec/controllers/groups_controller_spec.rb
719
724
  - base/spec/controllers/home_controller_spec.rb
@@ -771,6 +776,7 @@ files:
771
776
  - base/spec/factories/tie.rb
772
777
  - base/spec/factories/user.rb
773
778
  - base/spec/integration/navigation_spec.rb
779
+ - base/spec/integration/resque_access_spec.rb
774
780
  - base/spec/models/activity_action_spec.rb
775
781
  - base/spec/models/activity_authorization_spec.rb
776
782
  - base/spec/models/activity_spec.rb
@@ -951,6 +957,7 @@ files:
951
957
  - documents/lib/social_stream/documents/version.rb
952
958
  - documents/lib/social_stream/migrations/documents.rb
953
959
  - documents/lib/social_stream/views/toolbar/documents.rb
960
+ - documents/lib/tasks/db/populate_documents.rake
954
961
  - documents/social_stream-documents.gemspec
955
962
  - documents/spec/controllers/documents_controller_spec.rb
956
963
  - documents/spec/controllers/pictures_controller_spec.rb