-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable search scope name #71
Changes from all commits
b11d831
abe0131
e80e914
5ddd8bd
794d9fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,9 @@ module ClassMethods | |
def initialize_scopes | ||
scope :are_from, lambda { |*args| where(:sent_messageable_id => args.first, :sent_messageable_type => args.first.class.name) } | ||
scope :are_to, lambda { |*args| where(:received_messageable_id => args.first, :received_messageable_type => args.first.class.name) } | ||
scope :search, lambda { |*args| where("body like :search_txt or topic like :search_txt",:search_txt => "%#{args.first}%")} | ||
scope :connected_with, lambda { |*args| where("(sent_messageable_type = :sent_type and | ||
scope ActsAsMessageable.search_scope_name, | ||
lambda { |*args| where("body like :search_txt or topic like :search_txt", :search_txt => "%#{args.first}%") } | ||
scope :connected_with, lambda { |*args| where("(sent_messageable_type = :sent_type and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [97/80] |
||
sent_messageable_id = :sent_id and | ||
sender_delete = :s_delete and sender_permanent_delete = :s_perm_delete) or | ||
(received_messageable_type = :received_type and | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'spec_helper' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
describe 'configuration' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
share_examples_for :custom_search_scope_name do | ||
before do | ||
@reply_message = @message.reply("Re: Topic", "Body : I am fine") | ||
@reply_reply_message = @reply_message.reply("Re: Re: Topic", "Fine too") | ||
end | ||
|
||
it "bob should be able to search text from messages" do | ||
recordset = @bob.messages.text_search("I am fine") | ||
recordset.count.should == 1 | ||
recordset.should_not be_nil | ||
end | ||
end | ||
|
||
context 'without config block' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
before do | ||
ActsAsMessageable.search_scope_name = :text_search | ||
User.acts_as_messageable | ||
@message = send_message | ||
end | ||
|
||
describe "search text from messages using custom scope name" do | ||
it_behaves_like :custom_search_scope_name | ||
end | ||
end | ||
|
||
context 'with config block' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
before do | ||
ActsAsMessageable.config do |config| | ||
config.search_scope_name = :text_search | ||
end | ||
|
||
User.acts_as_messageable | ||
@message = send_message | ||
end | ||
|
||
describe "search text from messages using custom scope name" do | ||
it_behaves_like :custom_search_scope_name | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [143/80]
Align the parameters of a method call if they span more than one line.
Use the new Ruby 1.9 hash syntax.