Commit 9c003f99be7deb4f56b2947c91b520ea549ed4ff
Exists in
master
and in
29 other branches
Merge branch 'master' of https://gitlab.com/noosfero/noosfero into tolerance-time
Showing
58 changed files
with
534 additions
and
623 deletions
Show diff stats
.ackrc
Gemfile
1 | 1 | source "https://rubygems.org" |
2 | -gem 'rails' | |
3 | -gem 'fast_gettext' | |
4 | -gem 'acts-as-taggable-on' | |
5 | -gem 'prototype-rails' | |
6 | -gem 'prototype_legacy_helper', '0.0.0', :path => 'vendor/prototype_legacy_helper' | |
7 | -gem 'rails_autolink' | |
8 | -gem 'pg' | |
9 | -gem 'rmagick' | |
10 | -gem 'RedCloth' | |
11 | -gem 'will_paginate' | |
12 | -gem 'ruby-feedparser' | |
13 | -gem 'daemons' | |
14 | -gem 'thin' | |
15 | -gem 'hpricot' | |
16 | -gem 'nokogiri' | |
2 | +gem 'rails', '~> 3.2.19' | |
3 | +gem 'fast_gettext', '~> 0.6.8' | |
4 | +gem 'acts-as-taggable-on', '~> 3.0.2' | |
5 | +gem 'prototype-rails', '~> 3.2.1' | |
6 | +gem 'prototype_legacy_helper', '0.0.0', :path => 'vendor/prototype_legacy_helper' | |
7 | +gem 'rails_autolink', '~> 1.1.5' | |
8 | +gem 'pg', '~> 0.13.2' | |
9 | +gem 'rmagick', '~> 2.13.1' | |
10 | +gem 'RedCloth', '~> 4.2.9' | |
11 | +gem 'will_paginate', '~> 3.0.3' | |
12 | +gem 'ruby-feedparser', '~> 0.7' | |
13 | +gem 'daemons', '~> 1.1.5' | |
14 | +gem 'thin', '~> 1.3.1' | |
15 | +gem 'hpricot', '~> 0.8.6' | |
16 | +gem 'nokogiri', '~> 1.5.5' | |
17 | 17 | gem 'rake', :require => false |
18 | -gem 'rest-client' | |
19 | -gem 'exception_notification' | |
20 | -gem 'gettext', :require => false, :group => :development | |
18 | +gem 'rest-client', '~> 1.6.7' | |
19 | +gem 'exception_notification', '~> 4.0.1' | |
20 | +gem 'gettext', '~> 2.2.1', :require => false, :group => :development | |
21 | 21 | |
22 | 22 | # FIXME list here all actual dependencies (i.e. the ones in debian/control), |
23 | 23 | # with their GEM names (not the Debian package names) |
24 | 24 | |
25 | 25 | group :production do |
26 | - gem 'dalli' | |
26 | + gem 'dalli', '~> 2.7.0' | |
27 | 27 | end |
28 | 28 | |
29 | 29 | group :test do |
30 | - gem 'rspec' | |
31 | - gem 'rspec-rails' | |
32 | - gem 'mocha', :require => false | |
30 | + gem 'rspec', '~> 2.10.0' | |
31 | + gem 'rspec-rails', '~> 2.10.1' | |
32 | + gem 'mocha', '~> 1.1.0', :require => false | |
33 | 33 | end |
34 | 34 | |
35 | 35 | group :cucumber do |
36 | - gem 'cucumber-rails', :require => false | |
37 | - gem 'capybara' | |
38 | - gem 'cucumber' | |
39 | - gem 'database_cleaner' | |
40 | - gem 'selenium-webdriver' | |
36 | + gem 'cucumber-rails', '~> 1.0.6', :require => false | |
37 | + gem 'capybara', '~> 2.1.0' | |
38 | + gem 'cucumber', '~> 1.0.6' | |
39 | + gem 'database_cleaner', '~> 1.2.0' | |
40 | + gem 'selenium-webdriver', '~> 2.39.0' | |
41 | 41 | end |
42 | 42 | |
43 | 43 | # include plugin gemfiles | ... | ... |
Gemfile.lock
... | ... | @@ -1,195 +0,0 @@ |
1 | -PATH | |
2 | - remote: vendor/prototype_legacy_helper | |
3 | - specs: | |
4 | - prototype_legacy_helper (0.0.0) | |
5 | - | |
6 | -GEM | |
7 | - remote: https://rubygems.org/ | |
8 | - specs: | |
9 | - RedCloth (4.2.9) | |
10 | - actionmailer (3.2.6) | |
11 | - actionpack (= 3.2.6) | |
12 | - mail (~> 2.4.4) | |
13 | - actionpack (3.2.6) | |
14 | - activemodel (= 3.2.6) | |
15 | - activesupport (= 3.2.6) | |
16 | - builder (~> 3.0.0) | |
17 | - erubis (~> 2.7.0) | |
18 | - journey (~> 1.0.1) | |
19 | - rack (~> 1.4.0) | |
20 | - rack-cache (~> 1.2) | |
21 | - rack-test (~> 0.6.1) | |
22 | - sprockets (~> 2.1.3) | |
23 | - activemodel (3.2.6) | |
24 | - activesupport (= 3.2.6) | |
25 | - builder (~> 3.0.0) | |
26 | - activerecord (3.2.6) | |
27 | - activemodel (= 3.2.6) | |
28 | - activesupport (= 3.2.6) | |
29 | - arel (~> 3.0.2) | |
30 | - tzinfo (~> 0.3.29) | |
31 | - activeresource (3.2.6) | |
32 | - activemodel (= 3.2.6) | |
33 | - activesupport (= 3.2.6) | |
34 | - activesupport (3.2.6) | |
35 | - i18n (~> 0.6) | |
36 | - multi_json (~> 1.0) | |
37 | - acts-as-taggable-on (3.0.2) | |
38 | - rails (>= 3, < 5) | |
39 | - arel (3.0.2) | |
40 | - builder (3.0.0) | |
41 | - capybara (2.1.0) | |
42 | - mime-types (>= 1.16) | |
43 | - nokogiri (>= 1.3.3) | |
44 | - rack (>= 1.0.0) | |
45 | - rack-test (>= 0.5.4) | |
46 | - xpath (~> 2.0) | |
47 | - childprocess (0.3.3) | |
48 | - ffi (~> 1.0.6) | |
49 | - cucumber (1.0.6) | |
50 | - builder (>= 2.1.2) | |
51 | - diff-lcs (>= 1.1.2) | |
52 | - gherkin (~> 2.4.18) | |
53 | - json (>= 1.4.6) | |
54 | - term-ansicolor (>= 1.0.6) | |
55 | - cucumber-rails (1.0.6) | |
56 | - capybara (>= 1.1.1) | |
57 | - cucumber (>= 1.0.6) | |
58 | - nokogiri (>= 1.5.0) | |
59 | - daemons (1.1.5) | |
60 | - dalli (2.7.0) | |
61 | - database_cleaner (1.2.0) | |
62 | - diff-lcs (1.1.3) | |
63 | - erubis (2.7.0) | |
64 | - eventmachine (0.12.10) | |
65 | - exception_notification (4.0.1) | |
66 | - actionmailer (>= 3.0.4) | |
67 | - activesupport (>= 3.0.4) | |
68 | - fast_gettext (0.6.8) | |
69 | - ffi (1.0.11) | |
70 | - gettext (2.2.1) | |
71 | - locale | |
72 | - gherkin (2.4.21) | |
73 | - json (>= 1.4.6) | |
74 | - hike (1.2.1) | |
75 | - hpricot (0.8.6) | |
76 | - i18n (0.6.0) | |
77 | - journey (1.0.3) | |
78 | - json (1.7.3) | |
79 | - locale (2.0.5) | |
80 | - mail (2.4.4) | |
81 | - i18n (>= 0.4.0) | |
82 | - mime-types (~> 1.16) | |
83 | - treetop (~> 1.4.8) | |
84 | - metaclass (0.0.1) | |
85 | - mime-types (1.19) | |
86 | - mocha (0.11.3) | |
87 | - metaclass (~> 0.0.1) | |
88 | - multi_json (1.3.6) | |
89 | - nokogiri (1.5.5) | |
90 | - pg (0.13.2) | |
91 | - polyglot (0.3.3) | |
92 | - prototype-rails (3.2.1) | |
93 | - rails (~> 3.2) | |
94 | - rack (1.4.1) | |
95 | - rack-cache (1.2) | |
96 | - rack (>= 0.4) | |
97 | - rack-ssl (1.3.2) | |
98 | - rack | |
99 | - rack-test (0.6.1) | |
100 | - rack (>= 1.0) | |
101 | - rails (3.2.6) | |
102 | - actionmailer (= 3.2.6) | |
103 | - actionpack (= 3.2.6) | |
104 | - activerecord (= 3.2.6) | |
105 | - activeresource (= 3.2.6) | |
106 | - activesupport (= 3.2.6) | |
107 | - bundler (~> 1.0) | |
108 | - railties (= 3.2.6) | |
109 | - rails_autolink (1.1.5) | |
110 | - rails (> 3.1) | |
111 | - railties (3.2.6) | |
112 | - actionpack (= 3.2.6) | |
113 | - activesupport (= 3.2.6) | |
114 | - rack-ssl (~> 1.3.2) | |
115 | - rake (>= 0.8.7) | |
116 | - rdoc (~> 3.4) | |
117 | - thor (>= 0.14.6, < 2.0) | |
118 | - rake (0.9.2.2) | |
119 | - rdoc (3.9.4) | |
120 | - rest-client (1.6.7) | |
121 | - mime-types (>= 1.16) | |
122 | - rmagick (2.13.1) | |
123 | - rspec (2.10.0) | |
124 | - rspec-core (~> 2.10.0) | |
125 | - rspec-expectations (~> 2.10.0) | |
126 | - rspec-mocks (~> 2.10.0) | |
127 | - rspec-core (2.10.1) | |
128 | - rspec-expectations (2.10.0) | |
129 | - diff-lcs (~> 1.1.3) | |
130 | - rspec-mocks (2.10.1) | |
131 | - rspec-rails (2.10.1) | |
132 | - actionpack (>= 3.0) | |
133 | - activesupport (>= 3.0) | |
134 | - railties (>= 3.0) | |
135 | - rspec (~> 2.10.0) | |
136 | - ruby-feedparser (0.7) | |
137 | - rubyzip (1.1.2) | |
138 | - selenium-webdriver (2.39.0) | |
139 | - childprocess (>= 0.2.5) | |
140 | - multi_json (~> 1.0) | |
141 | - rubyzip (~> 1.0) | |
142 | - websocket (~> 1.0.4) | |
143 | - sprockets (2.1.3) | |
144 | - hike (~> 1.2) | |
145 | - multi_json (~> 1.0) | |
146 | - rack (~> 1.0) | |
147 | - tilt (~> 1.1, != 1.3.0) | |
148 | - term-ansicolor (1.0.7) | |
149 | - thin (1.3.1) | |
150 | - daemons (>= 1.0.9) | |
151 | - eventmachine (>= 0.12.6) | |
152 | - rack (>= 1.0.0) | |
153 | - thor (0.15.3) | |
154 | - tilt (1.3.3) | |
155 | - treetop (1.4.10) | |
156 | - polyglot | |
157 | - polyglot (>= 0.3.1) | |
158 | - tzinfo (0.3.33) | |
159 | - websocket (1.0.7) | |
160 | - will_paginate (3.0.3) | |
161 | - xpath (2.0.0) | |
162 | - nokogiri (~> 1.3) | |
163 | - | |
164 | -PLATFORMS | |
165 | - ruby | |
166 | - | |
167 | -DEPENDENCIES | |
168 | - RedCloth | |
169 | - acts-as-taggable-on | |
170 | - capybara | |
171 | - cucumber | |
172 | - cucumber-rails | |
173 | - daemons | |
174 | - dalli | |
175 | - database_cleaner | |
176 | - exception_notification | |
177 | - fast_gettext | |
178 | - gettext | |
179 | - hpricot | |
180 | - mocha | |
181 | - nokogiri | |
182 | - pg | |
183 | - prototype-rails | |
184 | - prototype_legacy_helper (= 0.0.0)! | |
185 | - rails | |
186 | - rails_autolink | |
187 | - rake | |
188 | - rest-client | |
189 | - rmagick | |
190 | - rspec | |
191 | - rspec-rails | |
192 | - ruby-feedparser | |
193 | - selenium-webdriver | |
194 | - thin | |
195 | - will_paginate |
Vagrantfile
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | |
4 | 4 | VAGRANTFILE_API_VERSION = "2" |
5 | 5 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
6 | - config.vm.box = "debian-wheezy" | |
6 | + config.vm.box = ENV.fetch('VAGRANT_BOX', "debian-wheezy") | |
7 | 7 | config.vm.network :forwarded_port, host: 3000, guest: 3000 |
8 | 8 | config.vm.provision :shell do |shell| |
9 | 9 | shell.inline = 'su vagrant -c /vagrant/script/vagrant' | ... | ... |
app/controllers/public/account_controller.rb
... | ... | @@ -97,6 +97,7 @@ class AccountController < ApplicationController |
97 | 97 | @user.return_to = session[:return_to] |
98 | 98 | @person = Person.new(params[:profile_data]) |
99 | 99 | @person.environment = @user.environment |
100 | + | |
100 | 101 | if request.post? |
101 | 102 | if may_be_a_bot |
102 | 103 | set_signup_start_time_for_now |
... | ... | @@ -115,6 +116,14 @@ class AccountController < ApplicationController |
115 | 116 | invitation.update_attributes!({:friend => @user.person}) |
116 | 117 | invitation.finish |
117 | 118 | end |
119 | + | |
120 | + unless params[:file].nil? | |
121 | + image = Image::new :uploaded_data=> params[:file][:image] | |
122 | + | |
123 | + @user.person.image = image | |
124 | + @user.person.save | |
125 | + end | |
126 | + | |
118 | 127 | if @user.activated? |
119 | 128 | self.current_user = @user |
120 | 129 | check_join_in_community(@user) | ... | ... |
app/models/environment.rb
... | ... | @@ -804,7 +804,7 @@ class Environment < ActiveRecord::Base |
804 | 804 | end |
805 | 805 | |
806 | 806 | def notification_emails |
807 | - [noreply_email.blank? ? nil : noreply_email].compact + admins.map(&:email) | |
807 | + [contact_email].select(&:present?) + admins.map(&:email) | |
808 | 808 | end |
809 | 809 | |
810 | 810 | after_create :create_templates | ... | ... |
app/models/organization.rb
... | ... | @@ -135,7 +135,11 @@ class Organization < Profile |
135 | 135 | end |
136 | 136 | |
137 | 137 | def notification_emails |
138 | - [contact_email.blank? ? nil : contact_email].compact + admins.map(&:email) | |
138 | + emails = [contact_email].select(&:present?) + admins.map(&:email) | |
139 | + if emails.empty? | |
140 | + emails << environment.contact_email | |
141 | + end | |
142 | + emails | |
139 | 143 | end |
140 | 144 | |
141 | 145 | def already_request_membership?(person) | ... | ... |
app/views/profile_editor/_person_form.html.erb
... | ... | @@ -25,6 +25,7 @@ |
25 | 25 | <%= optional_field(@person, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address, :rel => _('Address')))) %> |
26 | 26 | <%= optional_field(@person, 'address_reference', labelled_form_field(_('Address reference'), text_field(:profile_data, :address_reference, :rel => _('Address reference')))) %> |
27 | 27 | <%= optional_field(@person, 'district', labelled_form_field(_('District'), text_field(:profile_data, :district, :rel => _('District')))) %> |
28 | +<%= optional_field(@person, 'image', labelled_form_field(_('Image'), file_field(:file, :image, :rel => _('Image')))) %> | |
28 | 29 | |
29 | 30 | <% optional_field(@person, 'schooling') do %> |
30 | 31 | <div class="formfieldline"> | ... | ... |
config/cucumber.yml
1 | 1 | <% base_requires = '-r features/support -r features/step_definitions' %> |
2 | -<% default_options = "--color --format progress --strict --tags ~@selenium --tags ~@selenium-fixme --tags ~@fixme --exclude features/support/selenium.rb #{base_requires}" %> | |
2 | +<% default_options = "--format progress --strict --tags ~@selenium --tags ~@selenium-fixme --tags ~@fixme --exclude features/support/selenium.rb #{base_requires}" %> | |
3 | +<% | |
4 | + default_options += ' --color' if $stdout.isatty | |
5 | +%> | |
3 | 6 | <% selenium_options = "--strict --tags @selenium #{base_requires}" %> |
4 | 7 | |
5 | 8 | default: <%= default_options %> | ... | ... |
debian/control
debian/noosfero.install
debian/noosfero.links
... | ... | @@ -15,3 +15,4 @@ var/lib/noosfero-data/public/thumbnails usr/share/noosfero/public/th |
15 | 15 | usr/share/noosfero/public/designs/themes/noosfero usr/share/noosfero/public/designs/themes/default |
16 | 16 | usr/share/noosfero/public/designs/icons/tango usr/share/noosfero/public/designs/icons/default |
17 | 17 | usr/share/noosfero/script/noosfero-plugins usr/sbin/noosfero-plugins |
18 | +usr/share/noosfero/Gemfile.lock /dev/null | ... | ... |
gitignore.example
plugins/solr/config/solr.yml.dist
... | ... | @@ -9,18 +9,18 @@ |
9 | 9 | production: |
10 | 10 | url: http://127.0.0.1:8983/solr |
11 | 11 | jvm_options: -server -Xmx192M -Xms64M |
12 | - timeout: 0 | |
12 | + timeout: 600 | |
13 | 13 | data_path: /var/lib/noosfero-data/solr/index |
14 | 14 | |
15 | 15 | development: |
16 | 16 | url: http://0.0.0.0:8982/solr |
17 | 17 | jvm_options: -server -Xmx128M -Xms16M |
18 | - timeout: 0 | |
18 | + timeout: 600 | |
19 | 19 | |
20 | 20 | test: &TEST |
21 | 21 | url: http://0.0.0.0:8981/solr |
22 | 22 | jvm_options: -server -Xmx128M -Xms16M |
23 | - timeout: 0 | |
23 | + timeout: 600 | |
24 | 24 | |
25 | 25 | cucumber: |
26 | 26 | <<: *TEST | ... | ... |
plugins/solr/install.rb
plugins/solr/lib/ext/product.rb
... | ... | @@ -27,7 +27,8 @@ class Product |
27 | 27 | {:name => {:type => :text, :boost => 2.0}}, |
28 | 28 | {:description => :text}, {:category_full_name => :text}, |
29 | 29 | # filtered fields |
30 | - {:solr_plugin_public => :boolean}, {:environment_id => :integer}, | |
30 | + {:solr_plugin_public => :boolean}, | |
31 | + {:environment_id => :integer}, {:profile_id => :integer}, | |
31 | 32 | {:enabled => :boolean}, {:solr_plugin_category_filter => :integer}, |
32 | 33 | # ordered/query-boosted fields |
33 | 34 | {:solr_plugin_price_sortable => :decimal}, {:solr_plugin_name_sortable => :string}, | ... | ... |
plugins/solr/lib/ext/profile.rb
... | ... | @@ -42,7 +42,7 @@ class Profile |
42 | 42 | handle_asynchronously :solr_save |
43 | 43 | handle_asynchronously :solr_destroy |
44 | 44 | |
45 | - class_inheritable_accessor :solr_plugin_extra_index_methods | |
45 | + class_attribute :solr_plugin_extra_index_methods | |
46 | 46 | self.solr_plugin_extra_index_methods = [] |
47 | 47 | |
48 | 48 | def solr_plugin_extra_data_for_index | ... | ... |
plugins/solr/lib/solr_plugin.rb
... | ... | @@ -33,8 +33,8 @@ class SolrPlugin < Noosfero::Plugin |
33 | 33 | |
34 | 34 | solr_options = solr_options(class_asset(klass), category) |
35 | 35 | solr_options[:filter_queries] ||= [] |
36 | - solr_options[:filter_queries] += scopes_to_solr_filters scope, klass, options | |
37 | - solr_options.merge! products_options(user) if klass == Product and empty_query | |
36 | + solr_options[:filter_queries] += scopes_to_solr_options scope, klass, options | |
37 | + solr_options.merge! products_options(user) if asset == :products and empty_query | |
38 | 38 | solr_options.merge! options.except(:category, :filter) |
39 | 39 | |
40 | 40 | scope.find_by_contents query, paginate_options, solr_options |
... | ... | @@ -42,14 +42,14 @@ class SolrPlugin < Noosfero::Plugin |
42 | 42 | |
43 | 43 | protected |
44 | 44 | |
45 | - def scopes_to_solr_filters scope, klass = nil, options = {} | |
45 | + def scopes_to_solr_options scope, klass = nil, options = {} | |
46 | 46 | filter_queries = [] |
47 | 47 | klass ||= scope.base_class |
48 | 48 | solr_fields = klass.configuration[:solr_fields].keys |
49 | 49 | scopes_applied = scope.scopes_applied.dup rescue [] #rescue association and class direct filtering |
50 | 50 | |
51 | - scope.current_scoped_methods[:create].each do |attr, value| | |
52 | - next unless solr_fields.include? attr.to_sym | |
51 | + scope.scope_attributes.each do |attr, value| | |
52 | + raise "Non-indexed attribute '#{attr}' speficied in scope_attributes" unless solr_fields.include? attr.to_sym | |
53 | 53 | |
54 | 54 | # if the filter is present here, then prefer it |
55 | 55 | scopes_applied.reject!{ |name| name == attr.to_sym } | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/.travis.yml
1 | +services: | |
2 | + - mongodb | |
3 | + | |
4 | +language: ruby | |
5 | +rvm: | |
6 | + - 1.8.7 | |
7 | + | |
8 | +before_install: | |
9 | + - sudo apt-get update | |
10 | + - sudo apt-get install default-jdk | |
11 | + | |
1 | 12 | before_script: |
2 | 13 | - mongo mydb_test --eval 'db.addUser("travis", "test");' |
3 | 14 | - gem update --system 1.4.1 > /dev/null 2>&1 |
4 | 15 | - rake solr:download |
5 | 16 | - RAILS_ENV=test rake solr:start |
6 | 17 | |
7 | -script: "bundle exec rake $TASK --trace" | |
18 | +script: | |
19 | + - bundle exec rake test --trace | |
20 | + - bundle exec rake test:functional --trace | |
8 | 21 | |
9 | -rvm: | |
10 | - - 1.8.7 | |
11 | -env: | |
12 | - - TASK=test | |
13 | - - TASK=test:functional | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/Gemfile
plugins/solr/vendor/plugins/acts_as_solr_reloaded/Rakefile
1 | 1 | require 'rubygems' |
2 | 2 | require 'rake' |
3 | 3 | require 'rake/testtask' |
4 | -require 'rake/rdoctask' | |
4 | +require 'rdoc/task' | |
5 | 5 | |
6 | 6 | ENV['RAILS_ENV'] = "test" |
7 | 7 | require File.expand_path("#{File.dirname(__FILE__)}/config/solr_environment") |
8 | 8 | |
9 | 9 | Dir["#{File.dirname(__FILE__)}/lib/tasks/*.rake"].sort.each { |ext| load ext } |
10 | 10 | |
11 | -desc "Default Task" | |
12 | -task :default => [:test] | |
13 | - | |
14 | -desc "Runs the unit tests" | |
15 | -task :test => "test:unit" | |
16 | - | |
17 | -namespace :test do | |
18 | - task :setup do | |
19 | - DB ||= 'sqlite' | |
20 | - puts "Using " + DB | |
21 | - %x(mysql -u#{MYSQL_USER} < #{File.dirname(__FILE__) + "/test/fixtures/db_definitions/mysql.sql"}) if DB == 'mysql' | |
22 | - | |
23 | - Rake::Task["test:migrate"].invoke | |
24 | - end | |
25 | - | |
26 | - desc 'Measures test coverage using rcov' | |
27 | - task :rcov => :setup do | |
28 | - rm_f "coverage" | |
29 | - rm_f "coverage.data" | |
30 | - rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib" | |
31 | - | |
32 | - system("#{rcov} --html #{Dir.glob('test/**/*_shoulda.rb').join(' ')}") | |
33 | - system("open coverage/index.html") if PLATFORM['darwin'] | |
34 | - end | |
35 | - | |
36 | - desc 'Runs the functional tests, testing integration with Solr' | |
37 | - Rake::TestTask.new(:functional => :setup) do |t| | |
38 | - t.pattern = "test/functional/*_test.rb" | |
39 | - t.verbose = true | |
40 | - end | |
41 | - | |
42 | - desc "Unit tests" | |
43 | - Rake::TestTask.new(:unit => :setup) do |t| | |
44 | - t.libs << 'test/unit' | |
45 | - t.pattern = "test/unit/*_shoulda.rb" | |
46 | - t.verbose = true | |
47 | - end | |
48 | -end | |
49 | - | |
50 | -Rake::RDocTask.new do |rd| | |
51 | - rd.main = "README.rdoc" | |
52 | - rd.rdoc_dir = "rdoc" | |
53 | - rd.rdoc_files.exclude("lib/solr/**/*.rb", "lib/solr.rb") | |
54 | - rd.rdoc_files.include("README.rdoc", "lib/**/*.rb") | |
55 | -end | |
56 | - | |
57 | -begin | |
58 | - require 'jeweler' | |
59 | - Jeweler::Tasks.new do |s| | |
60 | - s.name = "acts_as_solr_reloaded" | |
61 | - s.summary = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model." | |
62 | - s.email = "dc.rec1@gmail.com" | |
63 | - s.homepage = "http://github.com/dcrec1/acts_as_solr_reloaded" | |
64 | - s.description = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model." | |
65 | - s.authors = ["Diego Carrion"] | |
66 | - s.files = FileList["[A-Z]*", "{bin,generators,config,lib,solr}/**/*"] + | |
67 | - FileList["test/**/*"].reject {|f| f.include?("test/log")}.reject {|f| f.include?("test/tmp")} | |
68 | - end | |
69 | -rescue LoadError | |
70 | - puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler" | |
71 | -end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb
... | ... | @@ -6,23 +6,19 @@ require 'net/http' |
6 | 6 | |
7 | 7 | dir = File.dirname(__FILE__) |
8 | 8 | SOLR_PATH = File.expand_path("#{dir}/../solr") unless defined? SOLR_PATH |
9 | -config = YAML::load_file(RAILS_ROOT+'/plugins/solr/config/solr.yml') | |
9 | +config = YAML::load_file("#{Rails.root}/plugins/solr/config/solr.yml") | |
10 | 10 | |
11 | -unless defined? RAILS_ROOT | |
12 | - # define RAILS_ROOT for test environment | |
13 | - RAILS_ROOT = defined?(Rails) ? Rails.root : File.expand_path("#{File.dirname(__FILE__)}/../test") | |
14 | -end | |
15 | 11 | unless defined? RAILS_ENV |
16 | 12 | RAILS_ENV = ENV['RAILS_ENV'] |
17 | 13 | end |
18 | 14 | unless defined? SOLR_LOGS_PATH |
19 | - SOLR_LOGS_PATH = ENV["SOLR_LOGS_PATH"] || "#{RAILS_ROOT}/log" | |
15 | + SOLR_LOGS_PATH = ENV["SOLR_LOGS_PATH"] || "#{Rails.root}/log" | |
20 | 16 | end |
21 | 17 | unless defined? SOLR_PIDS_PATH |
22 | - SOLR_PIDS_PATH = ENV["SOLR_PIDS_PATH"] || "#{RAILS_ROOT}/tmp/pids" | |
18 | + SOLR_PIDS_PATH = ENV["SOLR_PIDS_PATH"] || "#{Rails.root}/tmp/pids" | |
23 | 19 | end |
24 | 20 | unless defined? SOLR_DATA_PATH |
25 | - SOLR_DATA_PATH = ENV["SOLR_DATA_PATH"] || config[ENV['RAILS_ENV']]['data_path'] || "#{RAILS_ROOT}/solr/#{ENV['RAILS_ENV']}" | |
21 | + SOLR_DATA_PATH = ENV["SOLR_DATA_PATH"] || config[ENV['RAILS_ENV']]['data_path'] || "#{Rails.root}/solr/#{ENV['RAILS_ENV']}" | |
26 | 22 | end |
27 | 23 | unless defined? SOLR_CONFIG_PATH |
28 | 24 | SOLR_CONFIG_PATH = ENV["SOLR_CONFIG_PATH"] || "#{SOLR_PATH}/solr" | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr.rb
... | ... | @@ -20,6 +20,7 @@ require File.dirname(__FILE__) + '/acts_as_solr/search_results' |
20 | 20 | require File.dirname(__FILE__) + '/acts_as_solr/lazy_document' |
21 | 21 | require File.dirname(__FILE__) + '/acts_as_solr/mongo_mapper' |
22 | 22 | require File.dirname(__FILE__) + '/acts_as_solr/post' |
23 | +require File.dirname(__FILE__) + '/acts_as_solr/scope_with_applied_names' | |
23 | 24 | |
24 | 25 | # reopen ActiveRecord and include the acts_as_solr method |
25 | 26 | ActiveRecord::Base.extend ActsAsSolr::ActsMethods | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/acts_methods.rb
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/common_methods.rb
1 | 1 | module ActsAsSolr #:nodoc: |
2 | - | |
2 | + | |
3 | 3 | module CommonMethods |
4 | 4 | |
5 | 5 | TypeMapping = { |
... | ... | @@ -14,6 +14,7 @@ module ActsAsSolr #:nodoc: |
14 | 14 | :range_integer => "ri", |
15 | 15 | :facet => "facet", |
16 | 16 | :text => "t", |
17 | + :ngram_text => "nt", | |
17 | 18 | } |
18 | 19 | |
19 | 20 | # Converts field types into Solr types |
... | ... | @@ -39,39 +40,39 @@ module ActsAsSolr #:nodoc: |
39 | 40 | result = [result] unless result.is_a?(Array) |
40 | 41 | solr_batch_add result |
41 | 42 | end |
42 | - | |
43 | + | |
43 | 44 | # Sends an add command to Solr |
44 | 45 | def solr_add(add_xml) |
45 | 46 | ActsAsSolr::Post.execute(Solr::Request::AddDocument.new(add_xml)) |
46 | 47 | end |
47 | - | |
48 | + | |
48 | 49 | # Sends the delete command to Solr |
49 | 50 | def solr_delete(solr_ids) |
50 | 51 | ActsAsSolr::Post.execute(Solr::Request::Delete.new(:id => solr_ids)) |
51 | 52 | end |
52 | - | |
53 | + | |
53 | 54 | # Sends the commit command to Solr |
54 | 55 | def solr_commit |
55 | 56 | ActsAsSolr::Post.execute(Solr::Request::Commit.new) |
56 | 57 | end |
57 | - | |
58 | + | |
58 | 59 | # Optimizes the Solr index. Solr says: |
59 | - # | |
60 | - # Optimizations can take nearly ten minutes to run. | |
61 | - # We are presuming optimizations should be run once following large | |
60 | + # | |
61 | + # Optimizations can take nearly ten minutes to run. | |
62 | + # We are presuming optimizations should be run once following large | |
62 | 63 | # batch-like updates to the collection and/or once a day. |
63 | - # | |
64 | - # One of the solutions for this would be to create a cron job that | |
64 | + # | |
65 | + # One of the solutions for this would be to create a cron job that | |
65 | 66 | # runs every day at midnight and optmizes the index: |
66 | 67 | # 0 0 * * * /your_rails_dir/script/runner -e production "Model.solr_optimize" |
67 | - # | |
68 | + # | |
68 | 69 | def solr_optimize |
69 | 70 | ActsAsSolr::Post.execute(Solr::Request::Optimize.new) |
70 | 71 | end |
71 | - | |
72 | + | |
72 | 73 | # Returns the id for the given instance |
73 | - def record_id(object) | |
74 | - eval "object.#{object.class.primary_key}" | |
74 | + def record_id object | |
75 | + object.send object.class.primary_key | |
75 | 76 | end |
76 | 77 | end |
77 | 78 | end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/parser_methods.rb
... | ... | @@ -4,12 +4,16 @@ module ActsAsSolr #:nodoc: |
4 | 4 | |
5 | 5 | # Method used by mostly all the ClassMethods when doing a search |
6 | 6 | def parse_query(query=nil, options={}) |
7 | - valid_options = [:models, :lazy, :core, :results_format, :sql_options, | |
7 | + valid_options = [ | |
8 | + :models, :lazy, :core, :results_format, :sql_options, | |
8 | 9 | :alternate_query, :boost_functions, :filter_queries, :facets, :sort, |
9 | 10 | :scores, :operator, :latitude, :longitude, :radius, :relevance, :highlight, |
10 | - :offset, :per_page, :limit, :page,] | |
11 | + :offset, :per_page, :limit, :page, | |
12 | + :query_fields, :default_field, | |
13 | + ] | |
11 | 14 | query_options = {} |
12 | 15 | options[:results_format] ||= :objects |
16 | + options[:default_field] ||= 'text' | |
13 | 17 | |
14 | 18 | return if query.nil? |
15 | 19 | raise "Query should be a string" unless query.is_a?(String) |
... | ... | @@ -49,77 +53,95 @@ module ActsAsSolr #:nodoc: |
49 | 53 | query_options[:rows] = per_page |
50 | 54 | query_options[:start] = offset |
51 | 55 | |
56 | + query_options[:boost_functions] = replace_types([*options[:boost_functions]], '').join(' ') if options[:boost_functions] | |
57 | + | |
58 | + parse_facets query_options, options | |
59 | + parse_highlight query_options, options | |
60 | + parse_sort query_options, options | |
61 | + parse_location query_options, options | |
62 | + parse_query_fields query_options, options | |
63 | + | |
52 | 64 | query_options[:operator] = options[:operator] |
65 | + not_dismax = query_options[:operator] == :or | |
66 | + request = if not_dismax then Solr::Request::Standard.new(query_options) else Solr::Request::Dismax.new query_options end | |
67 | + ActsAsSolr::Post.execute request, options[:core] | |
68 | + rescue | |
69 | + raise "#{$query} There was a problem executing your search\n#{query_options.inspect}\n: #{$!} in #{$!.backtrace.first}" | |
70 | + end | |
71 | + end | |
53 | 72 | |
54 | - query_options[:boost_functions] = replace_types([*options[:boost_functions]], '').join(' ') if options[:boost_functions] | |
73 | + def parse_query_fields query_options, options | |
74 | + options[:query_fields] ||= [] | |
75 | + query_options[:query_fields] = replace_types([*options[:query_fields]], '').join ' ' | |
76 | + end | |
77 | + | |
78 | + def parse_sort query_options, options | |
79 | + query_options[:sort] = replace_types([*options[:sort]], '')[0] if options[:sort] | |
80 | + end | |
55 | 81 | |
56 | - # first steps on the facet parameter processing | |
57 | - if options[:facets] | |
58 | - query_options[:facets] = {} | |
59 | - query_options[:facets][:limit] = -1 # TODO: make this configurable | |
60 | - query_options[:facets][:sort] = :count if options[:facets][:sort] | |
61 | - query_options[:facets][:mincount] = 0 | |
62 | - query_options[:facets][:mincount] = 1 if options[:facets][:zeros] == false | |
63 | - # override the :zeros (it's deprecated anyway) if :mincount exists | |
64 | - query_options[:facets][:mincount] = options[:facets][:mincount] if options[:facets][:mincount] | |
65 | - query_options[:facets][:fields] = options[:facets][:fields].map{ |k| "#{k}_facet" } if options[:facets][:fields] | |
66 | - query_options[:filter_queries] += replace_types([*options[:facets][:browse]]) if options[:facets][:browse] | |
67 | - query_options[:facets][:queries] = replace_types([*options[:facets][:query]]) if options[:facets][:query] | |
68 | - | |
69 | - if options[:facets][:dates] | |
70 | - query_options[:date_facets] = {} | |
71 | - # if options[:facets][:dates][:fields] exists then :start, :end, and :gap must be there | |
72 | - if options[:facets][:dates][:fields] | |
73 | - [:start, :end, :gap].each { |k| raise "#{k} must be present in faceted date query" unless options[:facets][:dates].include?(k) } | |
74 | - query_options[:date_facets][:fields] = [] | |
75 | - options[:facets][:dates][:fields].each { |f| | |
76 | - if f.kind_of? Hash | |
77 | - key = f.keys[0] | |
78 | - query_options[:date_facets][:fields] << {"#{key}_d" => f[key]} | |
79 | - validate_date_facet_other_options(f[key][:other]) if f[key][:other] | |
80 | - else | |
81 | - query_options[:date_facets][:fields] << "#{f}_d" | |
82 | - end | |
83 | - } | |
84 | - end | |
85 | - | |
86 | - query_options[:date_facets][:start] = options[:facets][:dates][:start] if options[:facets][:dates][:start] | |
87 | - query_options[:date_facets][:end] = options[:facets][:dates][:end] if options[:facets][:dates][:end] | |
88 | - query_options[:date_facets][:gap] = options[:facets][:dates][:gap] if options[:facets][:dates][:gap] | |
89 | - query_options[:date_facets][:hardend] = options[:facets][:dates][:hardend] if options[:facets][:dates][:hardend] | |
90 | - query_options[:date_facets][:filter] = replace_types([*options[:facets][:dates][:filter]].collect{|k| "#{k.dup.sub!(/ *:(?!\d) */,"_d:")}"}) if options[:facets][:dates][:filter] | |
91 | - | |
92 | - if options[:facets][:dates][:other] | |
93 | - validate_date_facet_other_options(options[:facets][:dates][:other]) | |
94 | - query_options[:date_facets][:other] = options[:facets][:dates][:other] | |
95 | - end | |
82 | + def parse_location query_options, options | |
83 | + if options[:radius] | |
84 | + query_options[:radius] = options[:radius] | |
85 | + query_options[:filter_queries] << '{!geofilt}' | |
86 | + end | |
87 | + query_options[:latitude] = options[:latitude] | |
88 | + query_options[:longitude] = options[:longitude] | |
89 | + end | |
96 | 90 | |
91 | + def parse_highlight query_options, options | |
92 | + if options[:highlight] | |
93 | + query_options[:highlighting] = {} | |
94 | + query_options[:highlighting][:field_list] = replace_types([*options[:highlight][:fields]], '') if options[:highlight][:fields] | |
95 | + query_options[:highlighting][:require_field_match] = options[:highlight][:require_field_match] if options[:highlight][:require_field_match] | |
96 | + query_options[:highlighting][:max_snippets] = options[:highlight][:max_snippets] if options[:highlight][:max_snippets] | |
97 | + query_options[:highlighting][:prefix] = options[:highlight][:prefix] if options[:highlight][:prefix] | |
98 | + query_options[:highlighting][:suffix] = options[:highlight][:suffix] if options[:highlight][:suffix] | |
99 | + end | |
100 | + end | |
101 | + | |
102 | + def parse_facets query_options, options | |
103 | + # first steps on the facet parameter processing | |
104 | + if options[:facets] | |
105 | + query_options[:facets] = {} | |
106 | + query_options[:facets][:limit] = -1 # TODO: make this configurable | |
107 | + query_options[:facets][:sort] = :count if options[:facets][:sort] | |
108 | + query_options[:facets][:mincount] = 0 | |
109 | + query_options[:facets][:mincount] = 1 if options[:facets][:zeros] == false | |
110 | + # override the :zeros (it's deprecated anyway) if :mincount exists | |
111 | + query_options[:facets][:mincount] = options[:facets][:mincount] if options[:facets][:mincount] | |
112 | + query_options[:facets][:fields] = options[:facets][:fields].map{ |k| "#{k}_facet" } if options[:facets][:fields] | |
113 | + query_options[:filter_queries] += replace_types([*options[:facets][:browse]]) if options[:facets][:browse] | |
114 | + query_options[:facets][:queries] = replace_types([*options[:facets][:query]]) if options[:facets][:query] | |
115 | + | |
116 | + if options[:facets][:dates] | |
117 | + query_options[:date_facets] = {} | |
118 | + # if options[:facets][:dates][:fields] exists then :start, :end, and :gap must be there | |
119 | + if options[:facets][:dates][:fields] | |
120 | + [:start, :end, :gap].each { |k| raise "#{k} must be present in faceted date query" unless options[:facets][:dates].include?(k) } | |
121 | + query_options[:date_facets][:fields] = [] | |
122 | + options[:facets][:dates][:fields].each { |f| | |
123 | + if f.kind_of? Hash | |
124 | + key = f.keys[0] | |
125 | + query_options[:date_facets][:fields] << {"#{key}_d" => f[key]} | |
126 | + validate_date_facet_other_options(f[key][:other]) if f[key][:other] | |
127 | + else | |
128 | + query_options[:date_facets][:fields] << "#{f}_d" | |
129 | + end | |
130 | + } | |
97 | 131 | end |
98 | - end | |
99 | 132 | |
100 | - if options[:highlight] | |
101 | - query_options[:highlighting] = {} | |
102 | - query_options[:highlighting][:field_list] = replace_types([*options[:highlight][:fields]], '') if options[:highlight][:fields] | |
103 | - query_options[:highlighting][:require_field_match] = options[:highlight][:require_field_match] if options[:highlight][:require_field_match] | |
104 | - query_options[:highlighting][:max_snippets] = options[:highlight][:max_snippets] if options[:highlight][:max_snippets] | |
105 | - query_options[:highlighting][:prefix] = options[:highlight][:prefix] if options[:highlight][:prefix] | |
106 | - query_options[:highlighting][:suffix] = options[:highlight][:suffix] if options[:highlight][:suffix] | |
107 | - end | |
133 | + query_options[:date_facets][:start] = options[:facets][:dates][:start] if options[:facets][:dates][:start] | |
134 | + query_options[:date_facets][:end] = options[:facets][:dates][:end] if options[:facets][:dates][:end] | |
135 | + query_options[:date_facets][:gap] = options[:facets][:dates][:gap] if options[:facets][:dates][:gap] | |
136 | + query_options[:date_facets][:hardend] = options[:facets][:dates][:hardend] if options[:facets][:dates][:hardend] | |
137 | + query_options[:date_facets][:filter] = replace_types([*options[:facets][:dates][:filter]].collect{|k| "#{k.dup.sub!(/ *:(?!\d) */,"_d:")}"}) if options[:facets][:dates][:filter] | |
108 | 138 | |
109 | - query_options[:sort] = replace_types([*options[:sort]], '')[0] if options[:sort] | |
139 | + if options[:facets][:dates][:other] | |
140 | + validate_date_facet_other_options(options[:facets][:dates][:other]) | |
141 | + query_options[:date_facets][:other] = options[:facets][:dates][:other] | |
142 | + end | |
110 | 143 | |
111 | - if options[:radius] | |
112 | - query_options[:radius] = options[:radius] | |
113 | - query_options[:filter_queries] << '{!geofilt}' | |
114 | 144 | end |
115 | - query_options[:latitude] = options[:latitude] | |
116 | - query_options[:longitude] = options[:longitude] | |
117 | - | |
118 | - not_dismax = query_options[:operator] == :or | |
119 | - request = not_dismax ? Solr::Request::Standard.new(query_options) : Solr::Request::Dismax.new(query_options) | |
120 | - ActsAsSolr::Post.execute(request, options[:core]) | |
121 | - rescue | |
122 | - raise "#{$query} There was a problem executing your search\n#{query_options.inspect}\n: #{$!} in #{$!.backtrace.first}" | |
123 | 145 | end |
124 | 146 | end |
125 | 147 | |
... | ... | @@ -148,21 +170,21 @@ module ActsAsSolr #:nodoc: |
148 | 170 | results.update :start => header['params']['start'] |
149 | 171 | end |
150 | 172 | |
151 | - results.update(:facets => {'facet_fields' => []}) if options[:facets] | |
173 | + results.update(:facets => {'facet_fields' => {}}) if options[:facets] | |
152 | 174 | return SearchResults.new(results) if solr_data.total_hits == 0 |
153 | 175 | |
154 | 176 | results.update(:facets => solr_data.data['facet_counts']) if options[:facets] |
155 | 177 | |
156 | - ids = solr_data.hits.collect {|doc| doc["#{solr_configuration[:primary_key_field]}"]}.flatten | |
157 | - result = find_objects(ids, options) | |
158 | - results.update(:docs => result) | |
178 | + ids = solr_data.hits.collect{ |doc| doc["#{solr_configuration[:primary_key_field]}"] }.flatten | |
179 | + result = find_objects ids, options | |
180 | + results.update :ids => ids, :docs => result | |
159 | 181 | |
160 | 182 | add_scores(result, solr_data) if options[:results_format] == :objects and options[:scores] |
161 | 183 | |
162 | 184 | highlighted = {} |
163 | 185 | solr_data.highlighting.map do |x,y| |
164 | 186 | e={} |
165 | - y1=y.map{|x1,y1| e[x1.gsub(/_[^_]*/,"")]=y1} unless y.nil? | |
187 | + y.map{ |x1,y1| e[x1.gsub(/_[^_]*/,"")]=y1 } unless y.nil? | |
166 | 188 | highlighted[x.gsub(/[^:]*:/,"").to_i]=e |
167 | 189 | end unless solr_data.highlighting.nil? |
168 | 190 | results.update(:highlights => highlighted) |
... | ... | @@ -179,8 +201,12 @@ module ActsAsSolr #:nodoc: |
179 | 201 | ids.collect{ |id| ActsAsSolr::LazyDocument.new(id, self) } |
180 | 202 | elsif options[:results_format] == :objects |
181 | 203 | find_options = options[:sql_options] || {} |
182 | - find_options[:conditions] = self.send :merge_conditions, {self.primary_key => ids}, (find_options[:conditions] || []) | |
183 | - result = self.all(find_options) || [] | |
204 | + if Rails::VERSION::STRING >= '3.0' | |
205 | + result = self.scoped(find_options).where(self.primary_key => ids).all | |
206 | + else | |
207 | + find_options[:conditions] = self.send :merge_conditions, {self.primary_key => ids}, (find_options[:conditions] || []) | |
208 | + result = self.all(find_options) | |
209 | + end | |
184 | 210 | result = reorder(result, ids) unless find_options[:order] |
185 | 211 | result |
186 | 212 | elsif options[:results_format] == :none |
... | ... | @@ -226,22 +252,15 @@ module ActsAsSolr #:nodoc: |
226 | 252 | def add_scores(results, solr_data) |
227 | 253 | with_score = [] |
228 | 254 | solr_data.hits.each do |doc| |
229 | - with_score.push([doc["score"], | |
230 | - results.find {|record| scorable_record?(record, doc) }]) | |
231 | - end | |
232 | - with_score.each do |score, object| | |
233 | - class << object; attr_accessor :solr_score; end | |
234 | - object.solr_score = score | |
255 | + record = results.find do |result| | |
256 | + doc_id = doc["#{solr_configuration[:primary_key_field]}"].first rescue nil | |
257 | + record_id(result).to_s == doc_id | |
258 | + end | |
259 | + with_score.push [doc["score"], record] | |
235 | 260 | end |
236 | - end | |
237 | - | |
238 | - def scorable_record?(record, doc) | |
239 | - doc_id = doc["#{solr_configuration[:primary_key_field]}"] | |
240 | - if doc_id.nil? | |
241 | - doc_id = doc["id"] | |
242 | - "#{record.class.name}:#{record_id(record)}" == doc_id.first.to_s | |
243 | - else | |
244 | - record_id(record).to_s == doc_id.to_s | |
261 | + with_score.each do |score, record| | |
262 | + next unless record | |
263 | + record.solr_score = score | |
245 | 264 | end |
246 | 265 | end |
247 | 266 | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/scope_with_applied_names.rb
0 → 100644
... | ... | @@ -0,0 +1,91 @@ |
1 | + | |
2 | +if Rails::VERSION::STRING >= "3.2" | |
3 | + module ::ActiveRecord | |
4 | + | |
5 | + class Relation | |
6 | + attr_accessor :scopes_applied | |
7 | + end | |
8 | + | |
9 | + module Scoping | |
10 | + module Named | |
11 | + module ClassMethods | |
12 | + attr_accessor :scope_name, :scopes_applied | |
13 | + | |
14 | + def scope_with_applied_names name, scope_options = {} | |
15 | + name = name.to_sym | |
16 | + valid_scope_name?(name) | |
17 | + extension = Module.new(&Proc.new) if block_given? | |
18 | + | |
19 | + scope_proc = lambda do |*args| | |
20 | + options = scope_options.respond_to?(:call) ? unscoped { scope_options.call(*args) } : scope_options | |
21 | + options = scoped.apply_finder_options(options) if options.is_a?(Hash) | |
22 | + | |
23 | + relation = scoped.merge(options) | |
24 | + relation.scopes_applied ||= Set.new | |
25 | + relation.scopes_applied << name | |
26 | + | |
27 | + extension ? relation.extending(extension) : relation | |
28 | + end | |
29 | + | |
30 | + singleton_class.send(:redefine_method, name, &scope_proc) | |
31 | + end | |
32 | + alias_method_chain :scope, :applied_names | |
33 | + | |
34 | + end | |
35 | + end | |
36 | + end | |
37 | + end | |
38 | +else | |
39 | + require_dependency 'active_record/named_scope' | |
40 | + | |
41 | + module ::ActiveRecord | |
42 | + module NamedScope | |
43 | + module ClassMethods | |
44 | + | |
45 | + def named_scope_with_applied_names name, options = {}, &block | |
46 | + named_scope_without_applied_names name, options, &block | |
47 | + | |
48 | + name = name.to_sym | |
49 | + scopes[name] = lambda do |parent_scope, *args| | |
50 | + scope = Scope.new(parent_scope, case options | |
51 | + when Hash | |
52 | + options | |
53 | + when Proc | |
54 | + if self.model_name != parent_scope.model_name | |
55 | + options.bind(parent_scope).call(*args) | |
56 | + else | |
57 | + options.call(*args) | |
58 | + end | |
59 | + end, &block) | |
60 | + scope.scope_name = name | |
61 | + scope | |
62 | + end | |
63 | + end | |
64 | + alias_method_chain :named_scope, :applied_names | |
65 | + end | |
66 | + | |
67 | + class Scope | |
68 | + attr_accessor :scope_name, :scopes_applied | |
69 | + | |
70 | + def initialize_with_applied_names proxy_scope, options, &block | |
71 | + initialize_without_applied_names proxy_scope, options, &block | |
72 | + self.scopes_applied ||= [] | |
73 | + self.scopes_applied += proxy_scope.send :scopes_applied if Scope === proxy_scope | |
74 | + | |
75 | + # unrelated bugfix: use if instead of unless | |
76 | + if (Scope === proxy_scope || ActiveRecord::Associations::AssociationCollection === proxy_scope) | |
77 | + @current_scoped_methods_when_defined = proxy_scope.send(:current_scoped_methods) | |
78 | + end | |
79 | + end | |
80 | + alias_method_chain :initialize, :applied_names | |
81 | + | |
82 | + def scope_name= name | |
83 | + @scope_name = name | |
84 | + self.scopes_applied << @scope_name | |
85 | + end | |
86 | + | |
87 | + end | |
88 | + | |
89 | + end | |
90 | + end | |
91 | +end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/dismax.rb
... | ... | @@ -12,13 +12,15 @@ |
12 | 12 | |
13 | 13 | class Solr::Request::Dismax < Solr::Request::Standard |
14 | 14 | |
15 | - VALID_PARAMS.replace(VALID_PARAMS + [:tie_breaker, :query_fields, :minimum_match, :phrase_fields, :phrase_slop, | |
16 | - :alternate_query, :boost_query, :boost_functions]) | |
15 | + VALID_PARAMS.replace VALID_PARAMS + [ | |
16 | + :tie_breaker, :query_fields, :minimum_match, :phrase_fields, :phrase_slop, | |
17 | + :alternate_query, :boost_query, :boost_functions, | |
18 | + ] | |
17 | 19 | |
18 | 20 | def initialize(params) |
19 | 21 | super |
20 | 22 | end |
21 | - | |
23 | + | |
22 | 24 | def to_hash |
23 | 25 | hash = super |
24 | 26 | hash[:defType] = 'edismax' | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/standard.rb
... | ... | @@ -12,40 +12,42 @@ |
12 | 12 | |
13 | 13 | class Solr::Request::Standard < Solr::Request::Select |
14 | 14 | |
15 | - VALID_PARAMS = [:query, :sort, :default_field, :operator, :start, :rows, :shards, :date_facets, | |
16 | - :filter_queries, :field_list, :debug_query, :explain_other, :facets, :highlighting, :mlt, :radius, | |
17 | - :radius, :latitude, :longitude, :spellcheck] | |
18 | - | |
15 | + VALID_PARAMS = [ | |
16 | + :query, :sort, :default_field, :operator, :start, :rows, :shards, :date_facets, | |
17 | + :filter_queries, :field_list, :debug_query, :explain_other, :facets, :highlighting, :mlt, :radius, | |
18 | + :radius, :latitude, :longitude, :spellcheck, | |
19 | + ] | |
20 | + | |
19 | 21 | def initialize(params) |
20 | 22 | super 'search' |
21 | - | |
22 | - raise "Invalid parameters: #{(params.keys - VALID_PARAMS).join(',')}" unless | |
23 | + | |
24 | + raise "Invalid parameters: #{(params.keys - VALID_PARAMS).join(',')}" unless | |
23 | 25 | (params.keys - VALID_PARAMS).empty? |
24 | - | |
26 | + | |
25 | 27 | raise ":query parameter required" unless params[:query] |
26 | - | |
28 | + | |
27 | 29 | @params = params.dup |
28 | - | |
30 | + | |
29 | 31 | # Validate operator |
30 | 32 | if params[:operator] |
31 | - raise "Only :and/:or operators allowed" unless | |
33 | + raise "Only :and/:or operators allowed" unless | |
32 | 34 | [:and, :or].include?(params[:operator]) |
33 | - | |
35 | + | |
34 | 36 | @params[:operator] = params[:operator].to_s.upcase |
35 | 37 | end |
36 | 38 | |
37 | 39 | # Validate start, rows can be transformed to ints |
38 | 40 | @params[:start] = params[:start].to_i if params[:start] |
39 | 41 | @params[:rows] = params[:rows].to_i if params[:rows] |
40 | - | |
42 | + | |
41 | 43 | @params[:field_list] ||= ["*","score"] |
42 | - | |
44 | + | |
43 | 45 | @params[:shards] ||= [] |
44 | 46 | end |
45 | - | |
47 | + | |
46 | 48 | def to_hash |
47 | 49 | hash = {} |
48 | - | |
50 | + | |
49 | 51 | # standard request param processing |
50 | 52 | hash[:sort] = @params[:sort] |
51 | 53 | hash[:q] = @params[:query] |
... | ... | @@ -61,11 +63,11 @@ class Solr::Request::Standard < Solr::Request::Select |
61 | 63 | hash[:debugQuery] = @params[:debug_query] |
62 | 64 | hash[:explainOther] = @params[:explain_other] |
63 | 65 | hash[:shards] = @params[:shards].join(',') unless @params[:shards].empty? |
64 | - | |
66 | + | |
65 | 67 | hash[:sfield] = 'latlng' |
66 | 68 | hash[:d] = @params[:radius] |
67 | 69 | hash[:pt] = "#{@params[:latitude]}, #{@params[:longitude]}" if @params[:latitude] and @params[:longitude] |
68 | - | |
70 | + | |
69 | 71 | # facet parameter processing |
70 | 72 | if @params[:facets] |
71 | 73 | # TODO need validation of all that is under the :facets Hash too |
... | ... | @@ -95,7 +97,7 @@ class Solr::Request::Standard < Solr::Request::Select |
95 | 97 | end |
96 | 98 | end |
97 | 99 | end |
98 | - | |
100 | + | |
99 | 101 | if @params[:date_facets] |
100 | 102 | hash["facet.date"] = [] |
101 | 103 | if @params[:date_facets][:fields] |
... | ... | @@ -125,7 +127,7 @@ class Solr::Request::Standard < Solr::Request::Select |
125 | 127 | end |
126 | 128 | end |
127 | 129 | end |
128 | - | |
130 | + | |
129 | 131 | # highlighting parameter processing - http://wiki.apache.org/solr/HighlightingParameters |
130 | 132 | if @params[:highlighting] |
131 | 133 | hash[:hl] = true |
... | ... | @@ -385,7 +387,7 @@ class Solr::Request::Standard < Solr::Request::Select |
385 | 387 | end |
386 | 388 | |
387 | 389 | end |
388 | - | |
390 | + | |
389 | 391 | if @params[:mlt] |
390 | 392 | hash[:mlt] = true |
391 | 393 | hash["mlt.count"] = @params[:mlt][:count] |
... | ... | @@ -398,10 +400,10 @@ class Solr::Request::Standard < Solr::Request::Select |
398 | 400 | hash["mlt.maxntp"] = @params[:mlt][:max_tokens_parsed] |
399 | 401 | hash["mlt.boost"] = @params[:mlt][:boost] |
400 | 402 | end |
401 | - | |
403 | + | |
402 | 404 | hash[:spellcheck] = true |
403 | 405 | hash['spellcheck.collate'] = true |
404 | - | |
406 | + | |
405 | 407 | hash.merge(super.to_hash) |
406 | 408 | end |
407 | 409 | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/ruby.rb
... | ... | @@ -14,13 +14,14 @@ class Solr::Response::Ruby < Solr::Response::Base |
14 | 14 | attr_reader :data, :header |
15 | 15 | |
16 | 16 | def initialize(ruby_code) |
17 | + ruby_code.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
17 | 18 | super |
18 | 19 | begin |
19 | 20 | #TODO: what about pulling up data/header/response to ResponseBase, |
20 | 21 | # or maybe a new middle class like SelectResponseBase since |
21 | 22 | # all Select queries return this same sort of stuff?? |
22 | 23 | # XML (&wt=xml) and Ruby (&wt=ruby) responses contain exactly the same structure. |
23 | - # a goal of solrb is to make it irrelevant which gets used under the hood, | |
24 | + # a goal of solrb is to make it irrelevant which gets used under the hood, | |
24 | 25 | # but favor Ruby responses. |
25 | 26 | @data = eval(ruby_code) |
26 | 27 | @header = @data['responseHeader'] |
... | ... | @@ -38,5 +39,5 @@ class Solr::Response::Ruby < Solr::Response::Base |
38 | 39 | def query_time |
39 | 40 | @header['QTime'] |
40 | 41 | end |
41 | - | |
42 | + | |
42 | 43 | end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/xml.rb
... | ... | @@ -18,7 +18,7 @@ class Solr::Response::Xml < Solr::Response::Base |
18 | 18 | # parse the xml |
19 | 19 | @doc = REXML::Document.new(xml) |
20 | 20 | |
21 | - # look for the result code and string | |
21 | + # look for the result code and string | |
22 | 22 | # <?xml version="1.0" encoding="UTF-8"?> |
23 | 23 | # <response> |
24 | 24 | # <lst name="responseHeader"><int name="status">0</int><int name="QTime">2</int></lst> | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/database.rake
... | ... | @@ -5,12 +5,12 @@ namespace :db do |
5 | 5 | begin |
6 | 6 | ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "*:*")) |
7 | 7 | ActsAsSolr::Post.execute(Solr::Request::Commit.new) |
8 | - (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file| | |
8 | + (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file| | |
9 | 9 | ActsAsSolr::SolrFixtures.load(File.basename(fixture_file, '.*')) |
10 | - end | |
11 | - puts "The fixtures loaded have been added to Solr" | |
10 | + end | |
11 | + puts "The fixtures loaded have been added to Solr" | |
12 | 12 | rescue |
13 | 13 | end |
14 | 14 | end |
15 | 15 | end |
16 | -end | |
17 | 16 | \ No newline at end of file |
17 | +end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/jeweler.rake
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +begin | |
2 | + require 'jeweler' | |
3 | +rescue LoadError | |
4 | +end | |
5 | + | |
6 | +Jeweler::Tasks.new do |s| | |
7 | + s.name = "acts_as_solr_reloaded" | |
8 | + s.summary = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model." | |
9 | + s.email = "dc.rec1@gmail.com" | |
10 | + s.homepage = "http://github.com/dcrec1/acts_as_solr_reloaded" | |
11 | + s.description = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model." | |
12 | + s.authors = ["Diego Carrion"] | |
13 | + s.files = FileList["[A-Z]*", "{bin,generators,config,lib,solr}/**/*"] + | |
14 | + FileList["test/**/*"].reject {|f| f.include?("test/log")}.reject {|f| f.include?("test/tmp")} | |
15 | +end if defined? Jeweler | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/rdoc.rake
0 → 100644
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake
... | ... | @@ -158,7 +158,7 @@ namespace :solr do |
158 | 158 | |
159 | 159 | logger = ActiveRecord::Base.logger = Logger.new(STDOUT) |
160 | 160 | logger.level = ActiveSupport::BufferedLogger::INFO unless debug_output |
161 | - Dir["#{RAILS_ROOT}/app/models/*.rb"].each{ |file| require file } | |
161 | + Dir["#{Rails.root}/app/models/*.rb"].each{ |file| require file } | |
162 | 162 | |
163 | 163 | if start_server |
164 | 164 | puts "Starting Solr server..." | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/test.rake
plugins/solr/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/schema.xml
... | ... | @@ -57,11 +57,9 @@ |
57 | 57 | <fieldType name="text" class="solr.TextField" autoGeneratePhraseQueries="false"> |
58 | 58 | <analyzer type="index"> |
59 | 59 | <tokenizer class="solr.StandardTokenizerFactory"/> |
60 | - <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
61 | - | |
62 | 60 | <filter class="solr.ASCIIFoldingFilterFactory"/> |
63 | 61 | <filter class="solr.LowerCaseFilterFactory"/> |
64 | - | |
62 | + <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
65 | 63 | <filter class="solr.StopFilterFactory" words="stopwords.pt.txt" /> |
66 | 64 | |
67 | 65 | <!-- stemming |
... | ... | @@ -73,18 +71,12 @@ |
73 | 71 | <filter class="solr.HunspellStemFilterFactory" dictionary="en_US.dic" affix="en_US.aff" ignoreCase="true" /> |
74 | 72 | <filter class="solr.HunspellStemFilterFactory" dictionary="pt_PT.dic" affix="pt_PT.aff" ignoreCase="true" /> |
75 | 73 | --> |
76 | - | |
77 | - <!-- improvised stemming | |
78 | - <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" side="front"/> | |
79 | - --> | |
80 | 74 | </analyzer> |
81 | 75 | <analyzer type="query"> |
82 | 76 | <tokenizer class="solr.StandardTokenizerFactory"/> |
83 | - <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
84 | - | |
85 | 77 | <filter class="solr.ASCIIFoldingFilterFactory"/> |
86 | 78 | <filter class="solr.LowerCaseFilterFactory"/> |
87 | - | |
79 | + <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
88 | 80 | <filter class="solr.StopFilterFactory" words="stopwords.pt.txt" /> |
89 | 81 | |
90 | 82 | <!-- stemming |
... | ... | @@ -96,10 +88,23 @@ |
96 | 88 | <filter class="solr.HunspellStemFilterFactory" dictionary="en_US.dic" affix="en_US.aff" ignoreCase="true" /> |
97 | 89 | <filter class="solr.HunspellStemFilterFactory" dictionary="pt_PT.dic" affix="pt_PT.aff" ignoreCase="true" /> |
98 | 90 | --> |
91 | + </analyzer> | |
92 | + </fieldType> | |
99 | 93 | |
100 | - <!-- improvised stemming | |
101 | - <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" side="front"/> | |
102 | - --> | |
94 | + <fieldType name="ngramText" class="solr.TextField" positionIncrementGap="100"> | |
95 | + <analyzer type="index"> | |
96 | + <tokenizer class="solr.StandardTokenizerFactory"/> | |
97 | + <filter class="solr.ASCIIFoldingFilterFactory"/> | |
98 | + <filter class="solr.LowerCaseFilterFactory"/> | |
99 | + <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
100 | + | |
101 | + <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="20" side="front"/> | |
102 | + </analyzer> | |
103 | + <analyzer type="query"> | |
104 | + <tokenizer class="solr.StandardTokenizerFactory"/> | |
105 | + <filter class="solr.ASCIIFoldingFilterFactory"/> | |
106 | + <filter class="solr.LowerCaseFilterFactory"/> | |
107 | + <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
103 | 108 | </analyzer> |
104 | 109 | </fieldType> |
105 | 110 | |
... | ... | @@ -151,6 +156,7 @@ |
151 | 156 | <dynamicField name="*sortable_do" type="sdouble" indexed="true" stored="false" multiValued="false"/> |
152 | 157 | |
153 | 158 | <dynamicField name="*_t" type="text" indexed="true" stored="true" multiValued="true"/> |
159 | + <dynamicField name="*_nt" type="ngramText" indexed="true" stored="true" multiValued="true"/> | |
154 | 160 | <dynamicField name="*_s" type="text" indexed="true" stored="true" multiValued="false"/> |
155 | 161 | <dynamicField name="*_i" type="integer" indexed="true" stored="false" multiValued="true"/> |
156 | 162 | <dynamicField name="*_f" type="float" indexed="true" stored="true" multiValued="false"/> |
... | ... | @@ -168,6 +174,7 @@ |
168 | 174 | <field name="geo_distance" type="sdouble"/> <!-- Optional but used for distributed searching --> |
169 | 175 | |
170 | 176 | <field name="text" type="text" indexed="true" stored="false" multiValued="true"/> |
177 | + <field name="ngramText" type="ngramText" indexed="true" stored="false" multiValued="true"/> | |
171 | 178 | <field name="spell" type="textSpell" indexed="true" stored="true" multiValued="true"/> |
172 | 179 | |
173 | 180 | <dynamicField name="*_s_mv" type="string" indexed="true" stored="false" multiValued="true"/> |
... | ... | @@ -187,6 +194,10 @@ |
187 | 194 | <copyField source="*_do" dest="text"/> |
188 | 195 | <copyField source="*_facet" dest="text"/> |
189 | 196 | |
197 | + <copyField source="*_s" dest="ngramText"/> | |
198 | + <copyField source="*_t" dest="ngramText"/> | |
199 | + <copyField source="*_nt" dest="ngramText"/> | |
200 | + | |
190 | 201 | <copyField source="*_s" dest="spell"/> |
191 | 202 | <copyField source="*_t" dest="spell"/> |
192 | 203 | <copyField source="*_facet" dest="spell"/> | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/solr_test_rakefile.rb
plugins/solr/vendor/plugins/acts_as_solr_reloaded/test/fixtures/locals.yml
0 → 100644
plugins/solr/vendor/plugins/acts_as_solr_reloaded/test/test_helper.rb
... | ... | @@ -16,7 +16,7 @@ require 'mongo_mapper' |
16 | 16 | |
17 | 17 | class Rails |
18 | 18 | def self.root |
19 | - RAILS_ROOT | |
19 | + Rails.root | |
20 | 20 | end |
21 | 21 | |
22 | 22 | def self.env |
... | ... | @@ -26,13 +26,14 @@ end |
26 | 26 | |
27 | 27 | MongoMapper.database = "acts_as_solr_reloaded-test" |
28 | 28 | |
29 | -RAILS_ROOT = File.dirname(__FILE__) unless defined? RAILS_ROOT | |
30 | -RAILS_ENV = 'test' unless defined? RAILS_ENV | |
29 | +RAILS_ENV = 'test' unless defined? RAILS_ENV | |
31 | 30 | ENV["RAILS_ENV"] = "test" |
32 | 31 | |
33 | 32 | require File.expand_path(File.dirname(__FILE__) + '/../config/solr_environment') |
34 | 33 | require File.expand_path(File.dirname(__FILE__) + '/../lib/acts_as_solr') |
35 | 34 | |
35 | +ActiveRecord::Base.logger = Logger.new('/dev/null') | |
36 | + | |
36 | 37 | # Load Models |
37 | 38 | models_dir = File.join(File.dirname( __FILE__ ), 'models') |
38 | 39 | require "#{models_dir}/book.rb" |
... | ... | @@ -60,10 +61,10 @@ class Test::Unit::TestCase |
60 | 61 | klass = instance_eval table_name.to_s.capitalize.singularize |
61 | 62 | klass.find(:all).each{|content| content.solr_save} |
62 | 63 | end |
63 | - | |
64 | + | |
64 | 65 | clear_from_solr(:novels) |
65 | 66 | end |
66 | - | |
67 | + | |
67 | 68 | private |
68 | 69 | def self.clear_from_solr(table_name) |
69 | 70 | ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "type_s:#{table_name.to_s.capitalize.singularize}")) | ... | ... |
plugins/solr/vendor/plugins/named_scope_with_applied_names/init.rb
... | ... | @@ -1,57 +0,0 @@ |
1 | -require_dependency 'active_record/named_scope' | |
2 | - | |
3 | -if Rails::VERSION::STRING < "2.3.99" | |
4 | - | |
5 | - module ::ActiveRecord | |
6 | - | |
7 | - module NamedScope | |
8 | - | |
9 | - module ClassMethods | |
10 | - | |
11 | - def named_scope_with_applied_names name, options = {}, &block | |
12 | - named_scope_without_applied_names name, options, &block | |
13 | - | |
14 | - name = name.to_sym | |
15 | - scopes[name] = lambda do |parent_scope, *args| | |
16 | - scope = Scope.new(parent_scope, case options | |
17 | - when Hash | |
18 | - options | |
19 | - when Proc | |
20 | - if self.model_name != parent_scope.model_name | |
21 | - options.bind(parent_scope).call(*args) | |
22 | - else | |
23 | - options.call(*args) | |
24 | - end | |
25 | - end, &block) | |
26 | - scope.scope_name = name | |
27 | - scope | |
28 | - end | |
29 | - end | |
30 | - alias_method_chain :named_scope, :applied_names | |
31 | - end | |
32 | - | |
33 | - class Scope | |
34 | - attr_accessor :scope_name, :scopes_applied | |
35 | - | |
36 | - def initialize_with_applied_names proxy_scope, options, &block | |
37 | - initialize_without_applied_names proxy_scope, options, &block | |
38 | - self.scopes_applied ||= [] | |
39 | - self.scopes_applied += proxy_scope.send :scopes_applied if Scope === proxy_scope | |
40 | - | |
41 | - # unrelated bugfix: use if instead of unless | |
42 | - if (Scope === proxy_scope || ActiveRecord::Associations::AssociationCollection === proxy_scope) | |
43 | - @current_scoped_methods_when_defined = proxy_scope.send(:current_scoped_methods) | |
44 | - end | |
45 | - end | |
46 | - alias_method_chain :initialize, :applied_names | |
47 | - | |
48 | - def scope_name= name | |
49 | - @scope_name = name | |
50 | - self.scopes_applied << @scope_name | |
51 | - end | |
52 | - | |
53 | - end | |
54 | - | |
55 | - end | |
56 | - end | |
57 | -end |
script/install-dependencies/debian-wheezy.sh
... | ... | @@ -50,6 +50,13 @@ FPQAoNmiMgP6zGF9rgOEWMEiFEryayrz |
50 | 50 | EOF |
51 | 51 | fi |
52 | 52 | |
53 | +if test -f tmp/debian/Release.gpg; then | |
54 | + echo "deb file://$(pwd)/tmp/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list | |
55 | + sudo apt-key add tmp/debian/signing-key.asc | |
56 | +else | |
57 | + sudo rm -f /etc/apt/sources.list.d/local.list | |
58 | +fi | |
59 | + | |
53 | 60 | run sudo apt-get update |
54 | 61 | run sudo apt-get -qy dist-upgrade |
55 | 62 | ... | ... |
... | ... | @@ -0,0 +1,23 @@ |
1 | +#!/bin/sh | |
2 | + | |
3 | +export DEBIAN_INTERFACE=noninteractive | |
4 | + | |
5 | +#run sudo apt-get update | |
6 | +#run sudo apt-get dist-upgrade -qy | |
7 | + | |
8 | +run sudo apt-get install -qy dctrl-tools | |
9 | + | |
10 | +packages=$(grep-dctrl -n -s Build-Depends,Depends,Recommends -S -X noosfero debian/control | sed -e 's/([^)]*)//g; s/,\s*/\n/g' | grep -v 'rake\|ruby\|thin\|debhelper\|cucumber\|rail\|memcached\|debconf\|dbconfig-common\|misc:Depends\|adduser\|mail-transport-agent') | |
11 | + | |
12 | +run sudo apt-get install -qy ruby1.9.1-full build-essential libxml2-dev libxslt-dev libpq-dev libmagickcore-dev libmagickwand-dev $packages | |
13 | + | |
14 | + | |
15 | +export GEM_HOME=$(ruby -e 'puts Gem.user_dir') | |
16 | +export PATH="${GEM_HOME}/bin:${PATH}" | |
17 | +(gem list | grep bundler) || run gem install --no-rdoc --no-ri bundler | |
18 | +run bundle install | |
19 | + | |
20 | +sudo tee /etc/profile.d/rubygems-path.sh <<EOF | |
21 | +export GEM_HOME=\$(ruby -e 'puts Gem.user_dir') | |
22 | +PATH="\${GEM_HOME}/bin:\${PATH}" | |
23 | +EOF | ... | ... |
script/noosfero-plugins
script/quick-start
... | ... | @@ -2,12 +2,20 @@ |
2 | 2 | |
3 | 3 | say() { |
4 | 4 | msg="$@" |
5 | - printf "\033[1;34;49m%s\033[m\n" "$msg" | |
5 | + if [ -t 1 ]; then | |
6 | + printf "\033[1;34;49m%s\033[m\n" "$msg" | |
7 | + else | |
8 | + echo "$msg" | |
9 | + fi | |
6 | 10 | } |
7 | 11 | |
8 | 12 | complain() { |
9 | 13 | msg="$@" |
10 | - printf "\033[1;31;49m%s\033[m\n" "$msg" | |
14 | + if [ -t 1 ]; then | |
15 | + printf "\033[1;31;49m%s\033[m\n" "$msg" | |
16 | + else | |
17 | + echo "$msg" | |
18 | + fi | |
11 | 19 | } |
12 | 20 | |
13 | 21 | run() { | ... | ... |
test/factories.rb
... | ... | @@ -174,7 +174,11 @@ module Noosfero::Factory |
174 | 174 | ############################################### |
175 | 175 | |
176 | 176 | def defaults_for_environment |
177 | - { :name => 'Environment ' + factory_num_seq.to_s } | |
177 | + seq = factory_num_seq | |
178 | + { | |
179 | + :name => "Environment %d" % seq, | |
180 | + :contact_email => "environment%d@example.com" % seq | |
181 | + } | |
178 | 182 | end |
179 | 183 | |
180 | 184 | ############################################### | ... | ... |
test/functional/account_controller_test.rb
... | ... | @@ -637,6 +637,23 @@ class AccountControllerTest < ActionController::TestCase |
637 | 637 | assert_equal 'example.com', Person['testuser'].organization |
638 | 638 | end |
639 | 639 | |
640 | + should "create a new user with image" do | |
641 | + post :signup, :user => { | |
642 | + :login => 'testuser', :password => '123456', :password_confirmation => '123456', :email => 'testuser@example.com' | |
643 | + }, | |
644 | + :profile_data => { | |
645 | + :organization => 'example.com' | |
646 | + }, | |
647 | + :file => { | |
648 | + :image => fixture_file_upload('/files/rails.png', 'image/png') | |
649 | + } | |
650 | + | |
651 | + assert_response :success | |
652 | + | |
653 | + person = Person["testuser"] | |
654 | + assert_equal "rails.png", person.image.filename | |
655 | + end | |
656 | + | |
640 | 657 | should 'activate user after signup if environment is set to skip confirmation' do |
641 | 658 | env = Environment.default |
642 | 659 | env.enable('skip_new_user_email_confirmation') |
... | ... | @@ -965,6 +982,7 @@ class AccountControllerTest < ActionController::TestCase |
965 | 982 | end |
966 | 983 | |
967 | 984 | protected |
985 | + | |
968 | 986 | def new_user(options = {}, extra_options ={}) |
969 | 987 | data = {:profile_data => person_data} |
970 | 988 | if extra_options[:profile_data] | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -78,7 +78,7 @@ class ProfileControllerTest < ActionController::TestCase |
78 | 78 | |
79 | 79 | should 'actually add friend' do |
80 | 80 | login_as(@profile.identifier) |
81 | - person = fast_create(Person) | |
81 | + person = create_user.person | |
82 | 82 | assert_difference 'AddFriend.count' do |
83 | 83 | post :add, :profile => person.identifier |
84 | 84 | end |
... | ... | @@ -366,10 +366,10 @@ class ProfileControllerTest < ActionController::TestCase |
366 | 366 | assert profile.memberships.include?(community), 'profile should be actually added to the community' |
367 | 367 | end |
368 | 368 | |
369 | - should 'create task when join to closed organization with members' do | |
369 | + should 'create a task when joining a closed organization with members' do | |
370 | 370 | community = fast_create(Community) |
371 | 371 | community.update_attribute(:closed, true) |
372 | - admin = fast_create(Person) | |
372 | + admin = create_user.person | |
373 | 373 | community.add_member(admin) |
374 | 374 | |
375 | 375 | login_as profile.identifier |
... | ... | @@ -587,7 +587,7 @@ class ProfileControllerTest < ActionController::TestCase |
587 | 587 | should "leave a scrap on another profile" do |
588 | 588 | login_as(profile.identifier) |
589 | 589 | count = Scrap.count |
590 | - another_person = fast_create(Person) | |
590 | + another_person = create_user.person | |
591 | 591 | assert another_person.scraps_received.empty? |
592 | 592 | post :leave_scrap, :profile => another_person.identifier, :scrap => {:content => 'something'} |
593 | 593 | assert_equal count + 1, Scrap.count |
... | ... | @@ -645,7 +645,7 @@ class ProfileControllerTest < ActionController::TestCase |
645 | 645 | should "the sender be the logged user by default" do |
646 | 646 | login_as(profile.identifier) |
647 | 647 | count = Scrap.count |
648 | - another_person = fast_create(Person) | |
648 | + another_person = create_user.person | |
649 | 649 | post :leave_scrap, :profile => another_person.identifier, :scrap => {:content => 'something'} |
650 | 650 | last = Scrap.last |
651 | 651 | assert_equal profile, last.sender |
... | ... | @@ -654,7 +654,7 @@ class ProfileControllerTest < ActionController::TestCase |
654 | 654 | should "the receiver be the current profile by default" do |
655 | 655 | login_as(profile.identifier) |
656 | 656 | count = Scrap.count |
657 | - another_person = fast_create(Person) | |
657 | + another_person = create_user.person | |
658 | 658 | post :leave_scrap, :profile => another_person.identifier, :scrap => {:content => 'something'} |
659 | 659 | last = Scrap.last |
660 | 660 | assert_equal another_person, last.receiver |
... | ... | @@ -686,8 +686,8 @@ class ProfileControllerTest < ActionController::TestCase |
686 | 686 | end |
687 | 687 | |
688 | 688 | should 'not display activities of the current profile when he is not followed by the viewer' do |
689 | - p1= fast_create(Person) | |
690 | - p2= fast_create(Person) | |
689 | + p1= create_user.person | |
690 | + p2= create_user.person | |
691 | 691 | |
692 | 692 | UserStampSweeper.any_instance.stubs(:current_user).returns(p1) |
693 | 693 | scrap1 = create(Scrap, defaults_for_scrap(:sender => p1, :receiver => p2)) |
... | ... | @@ -714,9 +714,9 @@ class ProfileControllerTest < ActionController::TestCase |
714 | 714 | end |
715 | 715 | |
716 | 716 | should 'not see the friends activities in the current profile' do |
717 | - p2= fast_create(Person) | |
717 | + p2 = create_user.person | |
718 | 718 | assert !profile.is_a_friend?(p2) |
719 | - p3= fast_create(Person) | |
719 | + p3 = create_user.person | |
720 | 720 | p3.add_friend(profile) |
721 | 721 | assert p3.is_a_friend?(profile) |
722 | 722 | ActionTracker::Record.destroy_all |
... | ... | @@ -737,13 +737,13 @@ class ProfileControllerTest < ActionController::TestCase |
737 | 737 | end |
738 | 738 | |
739 | 739 | should 'see all the activities in the current profile network' do |
740 | - p1= fast_create(Person) | |
741 | - p2= fast_create(Person) | |
740 | + p1= create_user.person | |
741 | + p2= create_user.person | |
742 | 742 | assert !p1.is_a_friend?(p2) |
743 | 743 | |
744 | - p3= fast_create(Person) | |
744 | + p3= create_user.person | |
745 | 745 | p3.add_friend(p1) |
746 | - assert p3.is_a_friend?(p1) | |
746 | + p1.add_friend(p3) | |
747 | 747 | |
748 | 748 | ActionTracker::Record.delete_all |
749 | 749 | |
... | ... | @@ -759,27 +759,21 @@ class ProfileControllerTest < ActionController::TestCase |
759 | 759 | create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) |
760 | 760 | a3 = ActionTracker::Record.last |
761 | 761 | |
762 | - @controller.stubs(:logged_in?).returns(true) | |
763 | - user = mock() | |
764 | - user.stubs(:person).returns(p3) | |
765 | - user.stubs(:login).returns('some') | |
766 | - @controller.stubs(:current_user).returns(user) | |
767 | - Person.any_instance.stubs(:follows?).returns(true) | |
768 | - | |
769 | 762 | process_delayed_job_queue |
770 | - get :index, :profile => p1.identifier | |
771 | 763 | |
764 | + login_as p3.user.login | |
765 | + get :index, :profile => p1.identifier | |
772 | 766 | assert_equivalent [a1,a3].map(&:id), assigns(:network_activities).map(&:id) |
773 | 767 | end |
774 | 768 | |
775 | 769 | should 'the network activity be visible only to profile followers' do |
776 | - p1= fast_create(Person) | |
777 | - p2= fast_create(Person) | |
770 | + p1= create_user.person | |
771 | + p2= create_user.person | |
778 | 772 | assert !p1.is_a_friend?(p2) |
779 | 773 | |
780 | - p3= fast_create(Person) | |
774 | + p3= create_user.person | |
781 | 775 | p3.add_friend(p1) |
782 | - assert p3.is_a_friend?(p1) | |
776 | + p1.add_friend(p3) | |
783 | 777 | |
784 | 778 | ActionTracker::Record.delete_all |
785 | 779 | |
... | ... | @@ -795,24 +789,11 @@ class ProfileControllerTest < ActionController::TestCase |
795 | 789 | create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) |
796 | 790 | a3 = ActionTracker::Record.last |
797 | 791 | |
798 | - @controller.stubs(:logged_in?).returns(true) | |
799 | - user = mock() | |
800 | - user.stubs(:person).returns(p2) | |
801 | - user.stubs(:login).returns('some') | |
802 | - @controller.stubs(:current_user).returns(user) | |
792 | + process_delayed_job_queue | |
803 | 793 | |
794 | + login_as p2.user.login | |
804 | 795 | get :index, :profile => p1.identifier |
805 | 796 | assert assigns(:network_activities).blank? |
806 | - | |
807 | - user = mock() | |
808 | - user.stubs(:person).returns(p3) | |
809 | - user.stubs(:login).returns('some') | |
810 | - @controller.stubs(:current_user).returns(user) | |
811 | - Person.any_instance.stubs(:follows?).returns(true) | |
812 | - process_delayed_job_queue | |
813 | - | |
814 | - get :index, :profile => p3.identifier | |
815 | - assert_equivalent [a1,a3], assigns(:network_activities) | |
816 | 797 | end |
817 | 798 | |
818 | 799 | should 'the network activity be paginated' do |
... | ... | @@ -829,10 +810,10 @@ class ProfileControllerTest < ActionController::TestCase |
829 | 810 | end |
830 | 811 | |
831 | 812 | should 'the network activity be visible only to logged users' do |
832 | - p1= fast_create(Person) | |
833 | - p2= fast_create(Person) | |
813 | + p1= create_user.person | |
814 | + p2= create_user.person | |
834 | 815 | assert !p1.is_a_friend?(p2) |
835 | - p3= fast_create(Person) | |
816 | + p3= create_user.person | |
836 | 817 | p3.add_friend(p1) |
837 | 818 | assert p3.is_a_friend?(p1) |
838 | 819 | ActionTracker::Record.destroy_all |
... | ... | @@ -891,10 +872,10 @@ class ProfileControllerTest < ActionController::TestCase |
891 | 872 | end |
892 | 873 | |
893 | 874 | should 'the self activity not crashes with user not logged in' do |
894 | - p1= fast_create(Person) | |
895 | - p2= fast_create(Person) | |
875 | + p1= create_user.person | |
876 | + p2= create_user.person | |
896 | 877 | assert !p1.is_a_friend?(p2) |
897 | - p3= fast_create(Person) | |
878 | + p3= create_user.person | |
898 | 879 | p3.add_friend(p1) |
899 | 880 | assert p3.is_a_friend?(p1) |
900 | 881 | ActionTracker::Record.destroy_all | ... | ... |
test/functional/profile_editor_controller_test.rb
... | ... | @@ -865,7 +865,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
865 | 865 | |
866 | 866 | should 'not be able to destroy enterprise if is a regular member' do |
867 | 867 | enterprise = fast_create(Enterprise) |
868 | - enterprise.add_member(fast_create(Person)) # first member is admin by default | |
868 | + enterprise.add_member(create_user.person) # first member is admin by default | |
869 | 869 | |
870 | 870 | person = create_user('foo').person |
871 | 871 | enterprise.add_member(person) | ... | ... |
test/unit/article_test.rb
... | ... | @@ -1077,10 +1077,11 @@ class ArticleTest < ActiveSupport::TestCase |
1077 | 1077 | end |
1078 | 1078 | |
1079 | 1079 | should 'create the notification to organization and all organization members' do |
1080 | + Profile.delete_all | |
1080 | 1081 | ActionTracker::Record.delete_all |
1081 | 1082 | |
1082 | 1083 | community = fast_create(Community) |
1083 | - member_1 = Person.first | |
1084 | + member_1 = fast_create(Person) | |
1084 | 1085 | community.add_member(member_1) |
1085 | 1086 | |
1086 | 1087 | article = create TinyMceArticle, :name => 'Tracked Article 1', :profile_id => community.id | ... | ... |
test/unit/comment_notifier_test.rb
... | ... | @@ -57,15 +57,6 @@ class CommentNotifierTest < ActiveSupport::TestCase |
57 | 57 | assert_match /comment body/, sent.body.to_s |
58 | 58 | end |
59 | 59 | |
60 | - should 'not deliver mail if has no notification emails' do | |
61 | - community = fast_create(Community) | |
62 | - assert_equal [], community.notification_emails | |
63 | - article = fast_create(Article, :name => 'Article test', :profile_id => community.id, :notify_comments => true) | |
64 | - assert_no_difference 'ActionMailer::Base.deliveries.size' do | |
65 | - create_comment_and_notify(:author => @author, :title => 'test comment', :body => 'there is no addresses to send notification', :source => article) | |
66 | - end | |
67 | - end | |
68 | - | |
69 | 60 | should "deliver mail to followers" do |
70 | 61 | author = create_user('follower_author').person |
71 | 62 | follower = create_user('follower').person | ... | ... |
test/unit/environment_test.rb
... | ... | @@ -195,6 +195,12 @@ class EnvironmentTest < ActiveSupport::TestCase |
195 | 195 | assert !env.errors[:contact_email.to_s].present? |
196 | 196 | end |
197 | 197 | |
198 | + should 'notify contact email' do | |
199 | + env = Environment.new(:contact_email => 'foo@bar.com') | |
200 | + env.stubs(:admins).returns([]) | |
201 | + assert_equal ['foo@bar.com'], env.notification_emails | |
202 | + end | |
203 | + | |
198 | 204 | should 'provide a default hostname' do |
199 | 205 | env = fast_create(Environment) |
200 | 206 | env.domains << create(Domain, :name => 'example.com', :is_default => true) | ... | ... |
test/unit/feed_reader_block_test.rb
... | ... | @@ -53,7 +53,7 @@ class FeedReaderBlockTest < ActiveSupport::TestCase |
53 | 53 | end |
54 | 54 | |
55 | 55 | should 'display last fetched date' do |
56 | - now = Time.now | |
56 | + now = Time.new(2014,1,1) | |
57 | 57 | feed.feed_items = ['one', 'two'] |
58 | 58 | feed.fetched_at = now |
59 | 59 | assert_equal "Updated: #{show_date(now)}", feed.footer | ... | ... |
test/unit/organization_test.rb
... | ... | @@ -123,9 +123,9 @@ class OrganizationTest < ActiveSupport::TestCase |
123 | 123 | assert_equal ['admin1@email.com', 'admin2@email.com'], o.notification_emails |
124 | 124 | end |
125 | 125 | |
126 | - should 'return empty array if contact_email is a blank string and it has no admin' do | |
126 | + should 'use the environment contact email if no emails are listed here' do | |
127 | 127 | o = build(Organization, :contact_email => '', :environment => Environment.default) |
128 | - assert_equal [], o.notification_emails | |
128 | + assert_equal [o.environment.contact_email], o.notification_emails | |
129 | 129 | end |
130 | 130 | |
131 | 131 | should 'list pending enterprise validations' do | ... | ... |
test/unit/person_test.rb
... | ... | @@ -1198,8 +1198,8 @@ class PersonTest < ActiveSupport::TestCase |
1198 | 1198 | |
1199 | 1199 | should 'return tracked_actions and scraps as activities' do |
1200 | 1200 | ActionTracker::Record.destroy_all |
1201 | - person = fast_create(Person) | |
1202 | - another_person = fast_create(Person) | |
1201 | + person = create_user.person | |
1202 | + another_person = create_user.person | |
1203 | 1203 | |
1204 | 1204 | UserStampSweeper.any_instance.stubs(:current_user).returns(another_person) |
1205 | 1205 | scrap = create(Scrap, defaults_for_scrap(:sender => another_person, :receiver => person, :content => 'A scrap')) | ... | ... |
test/unit/profile_info_block_test.rb
test/unit/scrap_notifier_test.rb
... | ... | @@ -57,10 +57,10 @@ class ScrapNotifierTest < ActiveSupport::TestCase |
57 | 57 | |
58 | 58 | should 'not deliver mail if is a reply on a community' do |
59 | 59 | community = fast_create(Community) |
60 | - person = fast_create(Person) | |
60 | + person = create_user.person | |
61 | 61 | scrap = fast_create(Scrap, :receiver_id => community.id, :sender_id => @sender.id) |
62 | 62 | assert_no_difference 'ActionMailer::Base.deliveries.size' do |
63 | - Scrap.create!(:sender_id => person, :receiver_id => @sender.id, :scrap_id => scrap.id, :content => 'Hi myself!') | |
63 | + Scrap.create!(:sender_id => person.id, :receiver_id => @sender.id, :scrap_id => scrap.id, :content => 'Hi myself!') | |
64 | 64 | end |
65 | 65 | end |
66 | 66 | ... | ... |
test/unit/scrap_test.rb
... | ... | @@ -42,7 +42,7 @@ class ScrapTest < ActiveSupport::TestCase |
42 | 42 | end |
43 | 43 | |
44 | 44 | should "be associated to Person as sender" do |
45 | - person = fast_create(Person) | |
45 | + person = create_user.person | |
46 | 46 | s = Scrap.new |
47 | 47 | assert_nothing_raised do |
48 | 48 | s.sender = person |
... | ... | @@ -50,7 +50,7 @@ class ScrapTest < ActiveSupport::TestCase |
50 | 50 | end |
51 | 51 | |
52 | 52 | should "be associated to Person as receiver" do |
53 | - person = fast_create(Person) | |
53 | + person = create_user.person | |
54 | 54 | s = Scrap.new |
55 | 55 | assert_nothing_raised do |
56 | 56 | s.receiver = person |
... | ... | @@ -66,7 +66,7 @@ class ScrapTest < ActiveSupport::TestCase |
66 | 66 | end |
67 | 67 | |
68 | 68 | should "collect all scraps sent and received of a person" do |
69 | - person = fast_create(Person) | |
69 | + person = create_user.person | |
70 | 70 | s1 = fast_create(Scrap, :sender_id => person.id) |
71 | 71 | assert_equal [s1], Scrap.all_scraps(person) |
72 | 72 | s2 = fast_create(Scrap, :sender_id => person.id) |
... | ... | @@ -77,7 +77,7 @@ class ScrapTest < ActiveSupport::TestCase |
77 | 77 | |
78 | 78 | should "collect all scraps sent and received of a community" do |
79 | 79 | community = fast_create(Community) |
80 | - person = fast_create(Person) | |
80 | + person = create_user.person | |
81 | 81 | s1 = fast_create(Scrap, :sender_id => person.id) |
82 | 82 | assert_equal [], Scrap.all_scraps(community) |
83 | 83 | s2 = fast_create(Scrap, :receiver_id => community.id, :sender_id => person.id) |
... | ... | @@ -87,8 +87,8 @@ class ScrapTest < ActiveSupport::TestCase |
87 | 87 | end |
88 | 88 | |
89 | 89 | should "create the leave_scrap action tracker verb on scrap creation of one user to another" do |
90 | - p1 = fast_create(Person) | |
91 | - p2 = fast_create(Person) | |
90 | + p1 = create_user.person | |
91 | + p2 = create_user.person | |
92 | 92 | s = Scrap.new |
93 | 93 | s.sender= p1 |
94 | 94 | s.receiver= p2 |
... | ... | @@ -104,7 +104,7 @@ class ScrapTest < ActiveSupport::TestCase |
104 | 104 | end |
105 | 105 | |
106 | 106 | should "create the leave_scrap action tracker verb on scrap creation of one user to community" do |
107 | - p = fast_create(Person) | |
107 | + p = create_user.person | |
108 | 108 | c = fast_create(Community) |
109 | 109 | s = Scrap.new |
110 | 110 | s.sender= p |
... | ... | @@ -122,8 +122,8 @@ class ScrapTest < ActiveSupport::TestCase |
122 | 122 | end |
123 | 123 | |
124 | 124 | should "notify leave_scrap action tracker verb to friends and itself" do |
125 | - p1 = fast_create(Person) | |
126 | - p2 = fast_create(Person) | |
125 | + p1 = create_user.person | |
126 | + p2 = create_user.person | |
127 | 127 | p1.add_friend(p2) |
128 | 128 | ActionTrackerNotification.delete_all |
129 | 129 | Delayed::Job.delete_all |
... | ... | @@ -140,7 +140,7 @@ class ScrapTest < ActiveSupport::TestCase |
140 | 140 | end |
141 | 141 | |
142 | 142 | should "notify leave_scrap action tracker verb to members of the communities and the community itself" do |
143 | - p = fast_create(Person) | |
143 | + p = create_user.person | |
144 | 144 | c = fast_create(Community) |
145 | 145 | c.add_member(p) |
146 | 146 | ActionTrackerNotification.delete_all |
... | ... | @@ -158,7 +158,7 @@ class ScrapTest < ActiveSupport::TestCase |
158 | 158 | end |
159 | 159 | |
160 | 160 | should "create the leave_scrap_to_self action tracker verb on scrap creation of one user to itself" do |
161 | - p = fast_create(Person) | |
161 | + p = create_user.person | |
162 | 162 | s = Scrap.new |
163 | 163 | s.sender= p |
164 | 164 | s.receiver= p |
... | ... | @@ -172,8 +172,8 @@ class ScrapTest < ActiveSupport::TestCase |
172 | 172 | end |
173 | 173 | |
174 | 174 | should "notify leave_scrap_to_self action tracker verb to friends and itself" do |
175 | - p1 = fast_create(Person) | |
176 | - p2 = fast_create(Person) | |
175 | + p1 = create_user.person | |
176 | + p2 = create_user.person | |
177 | 177 | p1.add_friend(p2) |
178 | 178 | ActionTrackerNotification.delete_all |
179 | 179 | Delayed::Job.delete_all |
... | ... | @@ -216,7 +216,7 @@ class ScrapTest < ActiveSupport::TestCase |
216 | 216 | end |
217 | 217 | |
218 | 218 | should "update the scrap on reply creation" do |
219 | - person = fast_create(Person) | |
219 | + person = create_user.person | |
220 | 220 | s = fast_create(Scrap, :updated_at => DateTime.parse('2010-01-01')) |
221 | 221 | assert_equal DateTime.parse('2010-01-01'), s.updated_at.strftime('%Y-%m-%d') |
222 | 222 | DateTime.stubs(:now).returns(DateTime.parse('2010-09-07')) |
... | ... | @@ -242,20 +242,20 @@ class ScrapTest < ActiveSupport::TestCase |
242 | 242 | end |
243 | 243 | |
244 | 244 | should 'strip all html tags' do |
245 | - s, r = fast_create(Person), fast_create(Person) | |
245 | + s, r = create_user.person, create_user.person | |
246 | 246 | s = build Scrap, :sender => s, :receiver => r, :content => "<p>Test <b>Rails</b></p>" |
247 | 247 | assert_equal "Test Rails", s.strip_all_html_tags |
248 | 248 | end |
249 | 249 | |
250 | 250 | should 'strip html before save' do |
251 | - s, r = fast_create(Person), fast_create(Person) | |
251 | + s, r = create_user.person, create_user.person | |
252 | 252 | s = build Scrap, :sender => s, :receiver => r, :content => "<p>Test <b>Rails</b></p>" |
253 | 253 | s.save! |
254 | 254 | assert_equal "Test Rails", s.reload.content |
255 | 255 | end |
256 | 256 | |
257 | 257 | should 'strip html before validate' do |
258 | - s, r = fast_create(Person), fast_create(Person) | |
258 | + s, r = create_user.person, create_user.person | |
259 | 259 | s = build Scrap, :sender => s, :receiver => r, :content => "<p><b></b></p>" |
260 | 260 | assert !s.valid? |
261 | 261 | s.content = "<p>Test</p>" |
... | ... | @@ -272,7 +272,7 @@ class ScrapTest < ActiveSupport::TestCase |
272 | 272 | end |
273 | 273 | |
274 | 274 | should 'scrap wall url be the root scrap receiver url if it is a reply' do |
275 | - p1, p2 = fast_create(Person), fast_create(Person) | |
275 | + p1, p2 = create_user.person, create_user.person | |
276 | 276 | r = create Scrap, :sender => p1, :receiver => p2, :content => "Hello!" |
277 | 277 | s = build Scrap, :sender => p2, :receiver => p1, :content => "Hi!" |
278 | 278 | r.replies << s; s.reload |
... | ... | @@ -280,13 +280,13 @@ class ScrapTest < ActiveSupport::TestCase |
280 | 280 | end |
281 | 281 | |
282 | 282 | should 'scrap wall url be the scrap receiver url if it is not a reply' do |
283 | - p1, p2 = fast_create(Person), fast_create(Person) | |
283 | + p1, p2 = create_user.person, create_user.person | |
284 | 284 | s = create Scrap, :sender => p1, :receiver => p2, :content => "Hello!" |
285 | 285 | assert_equal s.scrap_wall_url, s.receiver.wall_url |
286 | 286 | end |
287 | 287 | |
288 | 288 | should 'create activity with reply_scrap_on_self when top_root scrap receiver is the same as sender' do |
289 | - s, r = fast_create(Person), fast_create(Person) | |
289 | + s, r = create_user.person, create_user.person | |
290 | 290 | root = fast_create(Scrap, :sender_id => s.id, :receiver_id => r.id) |
291 | 291 | assert_difference 'ActionTracker::Record.count', 1 do |
292 | 292 | reply = create(Scrap, :sender => r, :receiver => s, :scrap_id => root.id, :content => 'sample') | ... | ... |