hide saved search functionality if not enabled
This commit is contained in:
@@ -44,6 +44,12 @@ IQDB integration is now delegated to the [IQDBS service](https://github.com/r888
|
|||||||
You will need to install your own copy and enable the appropriate
|
You will need to install your own copy and enable the appropriate
|
||||||
configuration settings.
|
configuration settings.
|
||||||
|
|
||||||
|
### Listbooru Service
|
||||||
|
|
||||||
|
In order to access saved search functionality you will need to install and
|
||||||
|
configure the [Listbooru service](https://github.com/r888888888/listbooru).
|
||||||
|
|
||||||
### Archive Service
|
### Archive Service
|
||||||
|
|
||||||
In order to access versioned data for pools (and eventually posts) you will need to install and configure the [Archive service](https://github.com/r888888888/archives).
|
In order to access versioned data for pools (and eventually posts) you will
|
||||||
|
need to install and configure the [Archives service](https://github.com/r888888888/archives).
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class SavedSearchCategoryChangesController < ApplicationController
|
class SavedSearchCategoryChangesController < ApplicationController
|
||||||
before_filter :member_only
|
before_filter :member_only
|
||||||
|
before_filter :check_availabililty
|
||||||
respond_to :html
|
respond_to :html
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@@ -11,4 +12,22 @@ class SavedSearchCategoryChangesController < ApplicationController
|
|||||||
flash[:notice] = "Saved searches will be renamed"
|
flash[:notice] = "Saved searches will be renamed"
|
||||||
redirect_to saved_searches_path
|
redirect_to saved_searches_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_availabililty
|
||||||
|
if !SavedSearch.enabled?
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
|
flash[:notice] = "Listbooru service is not configured. Saved searches are not available."
|
||||||
|
redirect_to :back
|
||||||
|
end
|
||||||
|
format.json do
|
||||||
|
render json: {success: false, reason: "Listbooru service is not configured"}.to_json, status: 501
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class SavedSearchesController < ApplicationController
|
class SavedSearchesController < ApplicationController
|
||||||
before_filter :member_only
|
before_filter :member_only
|
||||||
|
before_fitler :check_availability
|
||||||
respond_to :html, :xml, :json, :js
|
respond_to :html, :xml, :json, :js
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@@ -47,6 +48,22 @@ class SavedSearchesController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def check_availabililty
|
||||||
|
if !SavedSearch.enabled?
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
|
flash[:notice] = "Listbooru service is not configured. Saved searches are not available."
|
||||||
|
redirect_to :back
|
||||||
|
end
|
||||||
|
format.json do
|
||||||
|
render json: {success: false, reason: "Listbooru service is not configured"}.to_json, status: 501
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def saved_searches
|
def saved_searches
|
||||||
CurrentUser.user.saved_searches
|
CurrentUser.user.saved_searches
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ module Moderator
|
|||||||
tags = Tag.scan_tags(antecedent, :strip_metatags => true)
|
tags = Tag.scan_tags(antecedent, :strip_metatags => true)
|
||||||
conds = tags.map {|x| "tag_query like ?"}.join(" AND ")
|
conds = tags.map {|x| "tag_query like ?"}.join(" AND ")
|
||||||
conds = [conds, *tags.map {|x| "%#{x}%"}]
|
conds = [conds, *tags.map {|x| "%#{x}%"}]
|
||||||
SavedSearch.where(*conds).find_each do |ss|
|
if SavedSearch.enabled?
|
||||||
ss.tag_query = (ss.tag_query_array - tags + antecedent).uniq.join(" ")
|
SavedSearch.where(*conds).find_each do |ss|
|
||||||
ss.save
|
ss.tag_query = (ss.tag_query_array - tags + antecedent).uniq.join(" ")
|
||||||
|
ss.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -102,15 +102,17 @@ class PostQueryBuilder
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_saved_search_relation(saved_searches, relation)
|
def add_saved_search_relation(saved_searches, relation)
|
||||||
saved_searches.each do |saved_search|
|
if SavedSearch.enabled?
|
||||||
if saved_search == "all"
|
saved_searches.each do |saved_search|
|
||||||
post_ids = SavedSearch.post_ids(CurrentUser.id)
|
if saved_search == "all"
|
||||||
else
|
post_ids = SavedSearch.post_ids(CurrentUser.id)
|
||||||
post_ids = SavedSearch.post_ids(CurrentUser.id, saved_search)
|
else
|
||||||
end
|
post_ids = SavedSearch.post_ids(CurrentUser.id, saved_search)
|
||||||
|
end
|
||||||
|
|
||||||
post_ids = [0] if post_ids.empty?
|
post_ids = [0] if post_ids.empty?
|
||||||
relation = relation.where(["posts.id IN (?)", post_ids])
|
relation = relation.where(["posts.id IN (?)", post_ids])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
relation
|
relation
|
||||||
|
|||||||
@@ -5,63 +5,96 @@ class SavedSearch < ActiveRecord::Base
|
|||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
|
def enabled?
|
||||||
|
Danbooru.config.aws_sqs_saved_search_url.present?
|
||||||
|
end
|
||||||
|
|
||||||
def posts_search_available?
|
def posts_search_available?
|
||||||
Danbooru.config.listbooru_server.present? && CurrentUser.is_gold?
|
enabled? && CurrentUser.is_gold?
|
||||||
|
end
|
||||||
|
|
||||||
|
def sqs_service
|
||||||
|
SqsService.new(Danbooru.config.aws_sqs_saved_search_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_listbooru(user_id)
|
def refresh_listbooru(user_id)
|
||||||
return false unless Danbooru.config.listbooru_enabled?
|
return false unless enabled?
|
||||||
|
|
||||||
sqs = SqsService.new(Danbooru.config.aws_sqs_queue_url)
|
sqs_service.send_message("refresh\n#{user_id}")
|
||||||
sqs.send_message("refresh\n#{user_id}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_listbooru(user_id)
|
def reset_listbooru(user_id)
|
||||||
return false unless Danbooru.config.listbooru_enabled?
|
return false unless enabled?
|
||||||
|
|
||||||
sqs = SqsService.new(Danbooru.config.aws_sqs_queue_url)
|
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
|
|
||||||
sqs.send_message("delete\n#{user_id}\nall\n")
|
sqs_service.send_message("delete\n#{user_id}\nall\n")
|
||||||
|
|
||||||
user.saved_searches.each do |saved_search|
|
user.saved_searches.each do |saved_search|
|
||||||
sqs.send_message("create\n#{user_id}\n#{saved_search.category}\n#{saved_search.tag_query}", :delay_seconds => 30)
|
sqs_service.send_message("create\n#{user_id}\n#{saved_search.category}\n#{saved_search.tag_query}", :delay_seconds => 30)
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def rename_listbooru(user_id, old_category, new_category)
|
def rename_listbooru(user_id, old_category, new_category)
|
||||||
return false unless Danbooru.config.listbooru_enabled?
|
return false unless enabled?
|
||||||
|
|
||||||
sqs = SqsService.new(Danbooru.config.aws_sqs_queue_url)
|
sqs_service.send_message("rename\n#{user_id}\n#{old_category}\n#{new_category}\n")
|
||||||
sqs.send_message("rename\n#{user_id}\n#{old_category}\n#{new_category}\n")
|
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def post_ids(user_id, name = nil)
|
||||||
|
return [] unless enabled?
|
||||||
|
|
||||||
|
if name
|
||||||
|
hash_name = Cache.hash(name)
|
||||||
|
else
|
||||||
|
hash_name = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
body = Cache.get("ss-pids-#{user_id}-#{hash_name}", 60) do
|
||||||
|
params = {
|
||||||
|
"key" => Danbooru.config.listbooru_auth_key,
|
||||||
|
"user_id" => user_id,
|
||||||
|
"name" => name
|
||||||
|
}
|
||||||
|
uri = URI.parse("#{Danbooru.config.listbooru_server}/users")
|
||||||
|
uri.query = URI.encode_www_form(params)
|
||||||
|
|
||||||
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.is_a?(URI::HTTPS)) do |http|
|
||||||
|
resp = http.request_get(uri.request_uri)
|
||||||
|
if resp.is_a?(Net::HTTPSuccess)
|
||||||
|
resp.body
|
||||||
|
else
|
||||||
|
raise "HTTP error code: #{resp.code} #{resp.message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
body.to_s.scan(/\d+/).map(&:to_i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_listbooru_on_create
|
def update_listbooru_on_create
|
||||||
return unless Danbooru.config.listbooru_enabled?
|
return unless SavedSearch.enabled?
|
||||||
return unless user.is_gold?
|
return unless user.is_gold?
|
||||||
|
|
||||||
sqs = SqsService.new(Danbooru.config.aws_sqs_queue_url)
|
SavedSearch.sqs_service.send_message("create\n#{user_id}\n#{category}\n#{tag_query}")
|
||||||
sqs.send_message("create\n#{user_id}\n#{category}\n#{tag_query}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_listbooru_on_destroy
|
def update_listbooru_on_destroy
|
||||||
return unless Danbooru.config.listbooru_enabled?
|
return unless SavedSearch.enabled?
|
||||||
|
|
||||||
sqs = SqsService.new(Danbooru.config.aws_sqs_queue_url)
|
SavedSearch.sqs_service.send_message("delete\n#{user_id}\n#{category}\n#{tag_query}")
|
||||||
sqs.send_message("delete\n#{user_id}\n#{category}\n#{tag_query}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_listbooru_on_update
|
def update_listbooru_on_update
|
||||||
return unless Danbooru.config.listbooru_enabled?
|
return unless SavedSearch.enabled?
|
||||||
return unless user.is_gold?
|
return unless user.is_gold?
|
||||||
|
|
||||||
sqs = SqsService.new(Danbooru.config.aws_sqs_queue_url)
|
SavedSearch.sqs_service.send_message("update\n#{user_id}\n#{category_was}\n#{tag_query_was}\n#{category}\n#{tag_query}")
|
||||||
sqs.send_message("update\n#{user_id}\n#{category_was}\n#{tag_query_was}\n#{category}\n#{tag_query}")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -99,37 +132,6 @@ class SavedSearch < ActiveRecord::Base
|
|||||||
rename_listbooru(user_id, old_category, new_category)
|
rename_listbooru(user_id, old_category, new_category)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.post_ids(user_id, name = nil)
|
|
||||||
return [] unless Danbooru.config.listbooru_enabled?
|
|
||||||
|
|
||||||
if name
|
|
||||||
hash_name = Cache.hash(name)
|
|
||||||
else
|
|
||||||
hash_name = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
body = Cache.get("ss-pids-#{user_id}-#{hash_name}", 60) do
|
|
||||||
params = {
|
|
||||||
"key" => Danbooru.config.listbooru_auth_key,
|
|
||||||
"user_id" => user_id,
|
|
||||||
"name" => name
|
|
||||||
}
|
|
||||||
uri = URI.parse("#{Danbooru.config.listbooru_server}/users")
|
|
||||||
uri.query = URI.encode_www_form(params)
|
|
||||||
|
|
||||||
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.is_a?(URI::HTTPS)) do |http|
|
|
||||||
resp = http.request_get(uri.request_uri)
|
|
||||||
if resp.is_a?(Net::HTTPSuccess)
|
|
||||||
resp.body
|
|
||||||
else
|
|
||||||
raise "HTTP error code: #{resp.code} #{resp.message}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
body.to_s.scan(/\d+/).map(&:to_i)
|
|
||||||
end
|
|
||||||
|
|
||||||
def normalize
|
def normalize
|
||||||
self.category = SavedSearch.normalize_category(category) if category
|
self.category = SavedSearch.normalize_category(category) if category
|
||||||
self.tag_query = SavedSearch.normalize(tag_query)
|
self.tag_query = SavedSearch.normalize(tag_query)
|
||||||
|
|||||||
@@ -180,9 +180,12 @@ class TagAlias < ActiveRecord::Base
|
|||||||
|
|
||||||
def move_saved_searches
|
def move_saved_searches
|
||||||
escaped = Regexp.escape(antecedent_name)
|
escaped = Regexp.escape(antecedent_name)
|
||||||
SavedSearch.where("tag_query like ?", "%#{antecedent_name}%").find_each do |ss|
|
|
||||||
ss.tag_query = ss.tag_query.sub(/(?:^| )#{escaped}(?:$| )/, " #{consequent_name} ").strip.gsub(/ /, " ")
|
if SavedSearch.enabled?
|
||||||
ss.save
|
SavedSearch.where("tag_query like ?", "%#{antecedent_name}%").find_each do |ss|
|
||||||
|
ss.tag_query = ss.tag_query.sub(/(?:^| )#{escaped}(?:$| )/, " #{consequent_name} ").strip.gsub(/ /, " ")
|
||||||
|
ss.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -847,15 +847,19 @@ class User < ActiveRecord::Base
|
|||||||
|
|
||||||
module SavedSearchMethods
|
module SavedSearchMethods
|
||||||
def unique_saved_search_categories
|
def unique_saved_search_categories
|
||||||
categories = saved_searches.pluck(:category)
|
if SavedSearch.enabled?
|
||||||
|
categories = saved_searches.pluck(:category)
|
||||||
if categories.any? {|x| x.blank?}
|
|
||||||
categories.reject! {|x| x.blank?}
|
if categories.any? {|x| x.blank?}
|
||||||
categories.unshift(SavedSearch::UNCATEGORIZED_NAME)
|
categories.reject! {|x| x.blank?}
|
||||||
|
categories.unshift(SavedSearch::UNCATEGORIZED_NAME)
|
||||||
|
end
|
||||||
|
|
||||||
|
categories.uniq!
|
||||||
|
categories
|
||||||
|
else
|
||||||
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
categories.uniq!
|
|
||||||
categories
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ class UserPresenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def posts_for_saved_search_category(category)
|
def posts_for_saved_search_category(category)
|
||||||
|
if !SavedSearch.enabled?
|
||||||
|
return Post.where("false")
|
||||||
|
end
|
||||||
|
|
||||||
if category == SavedSearch::UNCATEGORIZED_NAME
|
if category == SavedSearch::UNCATEGORIZED_NAME
|
||||||
ids = SavedSearch.post_ids(CurrentUser.user.id)
|
ids = SavedSearch.post_ids(CurrentUser.user.id)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
<% if CurrentUser.show_saved_searches? %>
|
<% if SavedSearch.enabled? && CurrentUser.show_saved_searches? %>
|
||||||
<%= button_tag "Save search", :id => "save-search" %>
|
<%= button_tag "Save search", :id => "save-search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div id="save-search-dialog" title="Save Search" style="display: none;">
|
<% if SavedSearch.enabled? %>
|
||||||
<%= form_tag(saved_searches_path, :class => "simple_form", :remote => true) do %>
|
<div id="save-search-dialog" title="Save Search" style="display: none;">
|
||||||
<%= hidden_field_tag "saved_search_tags", params[:tags] %>
|
<%= form_tag(saved_searches_path, :class => "simple_form", :remote => true) do %>
|
||||||
|
<%= hidden_field_tag "saved_search_tags", params[:tags] %>
|
||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<label>
|
<label>
|
||||||
<%= text_field_tag "saved_search_category", "", :placeholder => "Category" %>
|
<%= text_field_tag "saved_search_category", "", :placeholder => "Category" %>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><label><%= check_box_tag "saved_search_disable_categories" %> Disable categorization</label></p>
|
<p><label><%= check_box_tag "saved_search_disable_categories" %> Disable categorization</label></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
@@ -43,12 +43,14 @@
|
|||||||
<td>2,000</td>
|
<td>2,000</td>
|
||||||
<td>5,000</td>
|
<td>5,000</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<% if SavedSearch.enabled? %>
|
||||||
<td>Saved Searches</td>
|
<tr>
|
||||||
<td>No</td>
|
<td>Saved Searches</td>
|
||||||
<td>Yes</td>
|
<td>No</td>
|
||||||
<td>Yes</td>
|
<td>Yes</td>
|
||||||
</tr>
|
<td>Yes</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>See Censored Tags</td>
|
<td>See Censored Tags</td>
|
||||||
<td>No</td>
|
<td>No</td>
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ module Danbooru
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def aws_sqs_queue_url
|
def aws_sqs_saved_search_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def aws_sqs_reltagcalc_url
|
def aws_sqs_reltagcalc_url
|
||||||
|
|||||||
20
test/helpers/saved_search_test_helper.rb
Normal file
20
test/helpers/saved_search_test_helper.rb
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
module SavedSearchTestHelper
|
||||||
|
def mock_saved_search_service!
|
||||||
|
mock_sqs_service = Class.new do
|
||||||
|
def initialize
|
||||||
|
@commands = []
|
||||||
|
end
|
||||||
|
|
||||||
|
def commands
|
||||||
|
@commands
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_message(msg)
|
||||||
|
@commands << msg.split(/\n/).first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
service = mock_sqs_service.new
|
||||||
|
SavedSearch.stubs(:sqs_service).returns(service)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,13 +1,18 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
require 'helpers/saved_search_test_helper'
|
||||||
|
|
||||||
class SavedSearchTest < ActiveSupport::TestCase
|
class SavedSearchTest < ActiveSupport::TestCase
|
||||||
context "Fetching the post ids for a search" do
|
include SavedSearchTestHelper
|
||||||
setup do
|
|
||||||
Danbooru.config.stubs(:listbooru_enabled?).returns(true)
|
|
||||||
Danbooru.config.stubs(:listbooru_auth_key).returns("blahblahblah")
|
|
||||||
Danbooru.config.stubs(:listbooru_server).returns("http://localhost:3001")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def setup
|
||||||
|
super
|
||||||
|
mock_saved_search_service!
|
||||||
|
Danbooru.config.stubs(:listbooru_enabled?).returns(true)
|
||||||
|
Danbooru.config.stubs(:listbooru_auth_key).returns("blahblahblah")
|
||||||
|
Danbooru.config.stubs(:listbooru_server).returns("http://localhost:3001")
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Fetching the post ids for a search" do
|
||||||
context "with a name" do
|
context "with a name" do
|
||||||
should "return a list of ids" do
|
should "return a list of ids" do
|
||||||
MEMCACHE.expects(:get).returns(nil)
|
MEMCACHE.expects(:get).returns(nil)
|
||||||
@@ -31,7 +36,7 @@ class SavedSearchTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "Creating a saved search" do
|
context "Creating a saved search" do
|
||||||
setup do
|
setup do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:gold_user)
|
||||||
@saved_search = @user.saved_searches.create(:tag_query => " xxx ")
|
@saved_search = @user.saved_searches.create(:tag_query => " xxx ")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -43,12 +48,15 @@ class SavedSearchTest < ActiveSupport::TestCase
|
|||||||
should "normalize whitespace" do
|
should "normalize whitespace" do
|
||||||
assert_equal("xxx", @saved_search.tag_query)
|
assert_equal("xxx", @saved_search.tag_query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "send messages" do
|
||||||
|
assert_equal(%w(create), SavedSearch.sqs_service.commands)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Destroying a saved search" do
|
context "Destroying a saved search" do
|
||||||
setup do
|
setup do
|
||||||
SqsService.any_instance.stubs(:send_message)
|
@user = FactoryGirl.create(:gold_user)
|
||||||
@user = FactoryGirl.create(:user)
|
|
||||||
@saved_search = @user.saved_searches.create(:tag_query => "xxx")
|
@saved_search = @user.saved_searches.create(:tag_query => "xxx")
|
||||||
@saved_search.destroy
|
@saved_search.destroy
|
||||||
end
|
end
|
||||||
@@ -57,11 +65,15 @@ class SavedSearchTest < ActiveSupport::TestCase
|
|||||||
@user.reload
|
@user.reload
|
||||||
assert(!@user.has_saved_searches?, "should not have the saved_searches bitpref set")
|
assert(!@user.has_saved_searches?, "should not have the saved_searches bitpref set")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "send messages" do
|
||||||
|
assert_equal(%w(create delete), SavedSearch.sqs_service.commands)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "A user with max saved searches" do
|
context "A user with max saved searches" do
|
||||||
setup do
|
setup do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:gold_user)
|
||||||
User.any_instance.stubs(:max_saved_searches).returns(0)
|
User.any_instance.stubs(:max_saved_searches).returns(0)
|
||||||
@saved_search = @user.saved_searches.create(:tag_query => "xxx")
|
@saved_search = @user.saved_searches.create(:tag_query => "xxx")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user