Use webmock instead of fakeweb for VCR; Fix tests; Use Timecop to speed up tests previously using sleep; Move artist rename into seperate operation
This commit is contained in:
3
Gemfile
3
Gemfile
@@ -8,7 +8,8 @@ group :test do
|
||||
gem "simplecov", :require => false
|
||||
gem "pry"
|
||||
gem "vcr"
|
||||
gem "fakeweb"
|
||||
gem "webmock"
|
||||
gem "timecop"
|
||||
end
|
||||
|
||||
group :assets do
|
||||
|
||||
10
Gemfile.lock
10
Gemfile.lock
@@ -53,6 +53,7 @@ GEM
|
||||
activesupport (3.2.12)
|
||||
i18n (~> 0.6)
|
||||
multi_json (~> 1.0)
|
||||
addressable (2.3.4)
|
||||
arel (3.0.2)
|
||||
awesome_print (1.1.0)
|
||||
aws-s3 (0.6.3)
|
||||
@@ -73,6 +74,7 @@ GEM
|
||||
capistrano
|
||||
chronic (0.9.1)
|
||||
coderay (1.0.9)
|
||||
crack (0.3.2)
|
||||
daemons (1.1.9)
|
||||
delayed_job (3.0.5)
|
||||
activesupport (~> 3.0)
|
||||
@@ -87,7 +89,6 @@ GEM
|
||||
multi_json (~> 1.0)
|
||||
factory_girl (4.2.0)
|
||||
activesupport (>= 3.0.0)
|
||||
fakeweb (1.3.0)
|
||||
highline (1.6.18)
|
||||
hike (1.2.1)
|
||||
i18n (0.6.4)
|
||||
@@ -184,6 +185,7 @@ GEM
|
||||
ref
|
||||
thor (0.18.1)
|
||||
tilt (1.3.6)
|
||||
timecop (0.6.1)
|
||||
treetop (1.4.12)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
@@ -199,6 +201,9 @@ GEM
|
||||
rack
|
||||
raindrops (~> 0.7)
|
||||
vcr (2.4.0)
|
||||
webmock (1.11.0)
|
||||
addressable (>= 2.2.7)
|
||||
crack (>= 0.3.2)
|
||||
webrobots (0.1.1)
|
||||
whenever (0.8.2)
|
||||
activesupport (>= 2.3.4)
|
||||
@@ -218,7 +223,6 @@ DEPENDENCIES
|
||||
delayed_job_active_record
|
||||
diff-lcs
|
||||
factory_girl
|
||||
fakeweb
|
||||
ffaker!
|
||||
mechanize!
|
||||
memcache-client
|
||||
@@ -239,7 +243,9 @@ DEPENDENCIES
|
||||
simplecov
|
||||
term-ansicolor
|
||||
therubyracer
|
||||
timecop
|
||||
uglifier (>= 1.0.3)
|
||||
unicorn
|
||||
vcr
|
||||
webmock
|
||||
whenever
|
||||
|
||||
@@ -13,6 +13,17 @@ class ArtistsController < ApplicationController
|
||||
respond_with(@artist)
|
||||
end
|
||||
|
||||
def edit_name
|
||||
@artist = Artist.find(params[:id])
|
||||
respond_with(@artist)
|
||||
end
|
||||
|
||||
def update_name
|
||||
@artist = Artist.find(params[:id])
|
||||
@artist.update_attribute(:name, params[:artist][:name])
|
||||
respond_with(@artist)
|
||||
end
|
||||
|
||||
def banned
|
||||
@artists = Artist.where("is_banned = ?", true).order("name")
|
||||
respond_with(@artists) do |format|
|
||||
|
||||
@@ -148,18 +148,11 @@ class Artist < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def notes=(msg)
|
||||
if name_changed? && name_was.present?
|
||||
wiki_page = WikiPage.titled(name_was).first
|
||||
end
|
||||
|
||||
if wiki_page
|
||||
wiki_page.title = name
|
||||
wiki_page.body = msg
|
||||
wiki_page.save if wiki_page.body_changed? || wiki_page.title_changed?
|
||||
else
|
||||
if msg.present?
|
||||
self.wiki_page = WikiPage.new(:title => name, :body => msg)
|
||||
end
|
||||
elsif msg.present?
|
||||
self.wiki_page = WikiPage.new(:title => name, :body => msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -241,6 +241,10 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def promote_to(level)
|
||||
update_attributes({:level => level}, :as => :admin)
|
||||
end
|
||||
|
||||
def promote_to_admin_if_first_user
|
||||
return if Rails.env.test?
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<%= simple_form_for(@artist) do |f| %>
|
||||
<div class="input">
|
||||
<label for="artist_name">Name</label>
|
||||
<%= text_field "artist", "name" %>
|
||||
[<%= link_to "check", "#", :id => "check-name-link" %>]
|
||||
<span id="check-name-result"></span>
|
||||
<% if @artist.new_record? %>
|
||||
<%= text_field "artist", "name" %>
|
||||
[<%= link_to "check", "#", :id => "check-name-link" %>]
|
||||
<span id="check-name-result"></span>
|
||||
<% else %>
|
||||
<p><%= @artist.name %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= f.input :other_names_comma, :hint => "Separate with commas", :as => :text, :label => "Other names" %>
|
||||
<%= f.input :group_name %>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<li><%= link_to "Show", artist_path(@artist) %></li>
|
||||
<% if CurrentUser.is_member? %>
|
||||
<li><%= link_to "Edit", edit_artist_path(@artist) %></li>
|
||||
<li><%= link_to "Edit name", edit_name_artist_path(@artist) %></li>
|
||||
<% end %>
|
||||
<li><%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %></li>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
|
||||
19
app/views/artists/edit_name.html.erb
Normal file
19
app/views/artists/edit_name.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<div id="c-artists">
|
||||
<div id="a-edit">
|
||||
<%= render "sidebar" %>
|
||||
|
||||
<section id="content">
|
||||
<h1>Edit Artist Name</h1>
|
||||
<%= form_tag(update_name_artist_path(@artist), :method => :put) do %>
|
||||
<div class="input"><label for="artist_name">Name</label> <%= text_field :artist, :name %></div>
|
||||
<div><%= submit_tag "Submit" %></div>
|
||||
<% end %>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Edit Artist Name - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
@@ -59,6 +59,8 @@ Danbooru::Application.routes.draw do
|
||||
member do
|
||||
put :revert
|
||||
put :ban
|
||||
get :edit_name
|
||||
put :update_name
|
||||
end
|
||||
collection do
|
||||
get :show_or_new
|
||||
|
||||
2643
test/fixtures/vcr_cassettes/download-pixiv-html.yml
vendored
2643
test/fixtures/vcr_cassettes/download-pixiv-html.yml
vendored
File diff suppressed because it is too large
Load Diff
@@ -7,44 +7,44 @@ http_interactions:
|
||||
encoding: US-ASCII
|
||||
string: ''
|
||||
headers:
|
||||
referer:
|
||||
Referer:
|
||||
- http://www.pixiv.net
|
||||
user-agent:
|
||||
- ./2.8.0
|
||||
accept:
|
||||
User-Agent:
|
||||
- ./2.12.0
|
||||
Accept:
|
||||
- ! '*/*'
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
server:
|
||||
Server:
|
||||
- nginx
|
||||
date:
|
||||
- Fri, 03 May 2013 23:23:12 GMT
|
||||
content-type:
|
||||
Date:
|
||||
- Fri, 24 May 2013 19:51:22 GMT
|
||||
Content-Type:
|
||||
- image/png
|
||||
content-length:
|
||||
Content-Length:
|
||||
- '1782713'
|
||||
connection:
|
||||
Connection:
|
||||
- keep-alive
|
||||
last-modified:
|
||||
Last-Modified:
|
||||
- Wed, 14 Sep 2011 17:28:13 GMT
|
||||
etag:
|
||||
Etag:
|
||||
- ! '"2e3303bf-1b33b9-4acea15afa540"'
|
||||
accept-ranges:
|
||||
Accept-Ranges:
|
||||
- bytes
|
||||
cache-control:
|
||||
Cache-Control:
|
||||
- max-age=1209600
|
||||
expires:
|
||||
- Fri, 17 May 2013 23:23:12 GMT
|
||||
age:
|
||||
- '0'
|
||||
Expires:
|
||||
- Fri, 07 Jun 2013 00:30:29 GMT
|
||||
Age:
|
||||
- '69653'
|
||||
body:
|
||||
encoding: US-ASCII
|
||||
string: ''
|
||||
http_version: '1.1'
|
||||
recorded_at: Fri, 03 May 2013 23:23:12 GMT
|
||||
http_version:
|
||||
recorded_at: Fri, 24 May 2013 19:51:22 GMT
|
||||
- request:
|
||||
method: get
|
||||
uri: http://img65.pixiv.net/img/kiyoringo/21755794_big_p2.png
|
||||
@@ -52,39 +52,39 @@ http_interactions:
|
||||
encoding: US-ASCII
|
||||
string: ''
|
||||
headers:
|
||||
user-agent:
|
||||
- _/2.8.0
|
||||
referer:
|
||||
User-Agent:
|
||||
- _/2.12.0
|
||||
Referer:
|
||||
- http://www.pixiv.net
|
||||
accept:
|
||||
Accept:
|
||||
- ! '*/*'
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
server:
|
||||
Server:
|
||||
- nginx
|
||||
date:
|
||||
- Fri, 03 May 2013 23:23:12 GMT
|
||||
content-type:
|
||||
Date:
|
||||
- Fri, 24 May 2013 19:51:22 GMT
|
||||
Content-Type:
|
||||
- image/png
|
||||
content-length:
|
||||
Content-Length:
|
||||
- '1782713'
|
||||
connection:
|
||||
Connection:
|
||||
- keep-alive
|
||||
last-modified:
|
||||
Last-Modified:
|
||||
- Wed, 14 Sep 2011 17:28:13 GMT
|
||||
etag:
|
||||
Etag:
|
||||
- ! '"2e3303bf-1b33b9-4acea15afa540"'
|
||||
accept-ranges:
|
||||
Accept-Ranges:
|
||||
- bytes
|
||||
cache-control:
|
||||
Cache-Control:
|
||||
- max-age=1209600
|
||||
expires:
|
||||
- Fri, 17 May 2013 23:23:12 GMT
|
||||
age:
|
||||
- '0'
|
||||
Expires:
|
||||
- Fri, 07 Jun 2013 00:30:29 GMT
|
||||
Age:
|
||||
- '69653'
|
||||
body:
|
||||
encoding: ASCII-8BIT
|
||||
string: !binary |-
|
||||
@@ -39704,6 +39704,6 @@ http_interactions:
|
||||
AgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAAB
|
||||
AgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAAB
|
||||
AgQIECBAgAABAgQIECDwAYE/YMgpRKYZ7IsAAAAASUVORK5CYII=
|
||||
http_version: '1.1'
|
||||
recorded_at: Fri, 03 May 2013 23:23:17 GMT
|
||||
http_version:
|
||||
recorded_at: Fri, 24 May 2013 19:51:25 GMT
|
||||
recorded_with: VCR 2.4.0
|
||||
|
||||
@@ -7,51 +7,39 @@ http_interactions:
|
||||
encoding: US-ASCII
|
||||
string: ''
|
||||
headers:
|
||||
user-agent:
|
||||
- _/2.8.0
|
||||
referer:
|
||||
User-Agent:
|
||||
- _/2.12.0
|
||||
Referer:
|
||||
- http://www.pixiv.net
|
||||
accept:
|
||||
Accept:
|
||||
- ! '*/*'
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: !binary |-
|
||||
T0s=
|
||||
message: OK
|
||||
headers:
|
||||
!binary "c2VydmVy":
|
||||
- !binary |-
|
||||
bmdpbng=
|
||||
!binary "ZGF0ZQ==":
|
||||
- !binary |-
|
||||
RnJpLCAwMyBNYXkgMjAxMyAyMzoyMzoxOCBHTVQ=
|
||||
!binary "Y29udGVudC10eXBl":
|
||||
- !binary |-
|
||||
aW1hZ2UvanBlZw==
|
||||
!binary "Y29udGVudC1sZW5ndGg=":
|
||||
- !binary |-
|
||||
MTg1Nzc4
|
||||
!binary "Y29ubmVjdGlvbg==":
|
||||
- !binary |-
|
||||
a2VlcC1hbGl2ZQ==
|
||||
!binary "bGFzdC1tb2RpZmllZA==":
|
||||
- !binary |-
|
||||
VHVlLCAxOSBNYXkgMjAwOSAyMzozNDoxMSBHTVQ=
|
||||
!binary "ZXRhZw==":
|
||||
- !binary |-
|
||||
ImFkZDExYzktMmQ1YjItNDZhNGM1OTBlMjJjMCI=
|
||||
!binary "YWNjZXB0LXJhbmdlcw==":
|
||||
- !binary |-
|
||||
Ynl0ZXM=
|
||||
!binary "Y2FjaGUtY29udHJvbA==":
|
||||
- !binary |-
|
||||
bWF4LWFnZT0xMjA5NjAw
|
||||
!binary "ZXhwaXJlcw==":
|
||||
- !binary |-
|
||||
RnJpLCAxNyBNYXkgMjAxMyAxMTozMTozMyBHTVQ=
|
||||
!binary "YWdl":
|
||||
- !binary |-
|
||||
NDI3MDU=
|
||||
Server:
|
||||
- nginx
|
||||
Date:
|
||||
- Fri, 24 May 2013 19:51:25 GMT
|
||||
Content-Type:
|
||||
- image/jpeg
|
||||
Content-Length:
|
||||
- '185778'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Last-Modified:
|
||||
- Tue, 19 May 2009 23:34:11 GMT
|
||||
Etag:
|
||||
- ! '"add11c9-2d5b2-46a4c590e22c0"'
|
||||
Accept-Ranges:
|
||||
- bytes
|
||||
Cache-Control:
|
||||
- max-age=1209600
|
||||
Expires:
|
||||
- Thu, 06 Jun 2013 22:56:47 GMT
|
||||
Age:
|
||||
- '75278'
|
||||
body:
|
||||
encoding: ASCII-8BIT
|
||||
string: !binary |-
|
||||
@@ -4184,7 +4172,6 @@ http_interactions:
|
||||
DvGOzZcGUrHy3Ep4MunzY5Ue4KSoe+oGXGtuq4FVkqjqSa+gLfx3N0nxMF54
|
||||
uS9vPLxbgUolXkf60QkHs5F291RMWfqRh/kmOpY7fIklQbpB7wD9danFlWB5
|
||||
bJUdD6Cp8Tgup+OwhWnRD//Z
|
||||
http_version: !binary |-
|
||||
MS4x
|
||||
recorded_at: Fri, 03 May 2013 23:23:18 GMT
|
||||
http_version:
|
||||
recorded_at: Fri, 24 May 2013 19:51:26 GMT
|
||||
recorded_with: VCR 2.4.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2614
test/fixtures/vcr_cassettes/source-pixiv-unit-test.yml
vendored
2614
test/fixtures/vcr_cassettes/source-pixiv-unit-test.yml
vendored
File diff suppressed because it is too large
Load Diff
@@ -92,6 +92,6 @@ MEMCACHE = MockMemcache.new
|
||||
|
||||
VCR.configure do |c|
|
||||
c.cassette_library_dir = "test/fixtures/vcr_cassettes"
|
||||
c.hook_into :fakeweb
|
||||
c.hook_into :webmock
|
||||
c.allow_http_connections_when_no_cassette = true
|
||||
end
|
||||
|
||||
@@ -67,8 +67,9 @@ class CommentTest < ActiveSupport::TestCase
|
||||
Danbooru.config.stubs(:comment_threshold).returns(1)
|
||||
p = FactoryGirl.create(:post)
|
||||
c1 = FactoryGirl.create(:comment, :post => p)
|
||||
sleep 1
|
||||
c2 = FactoryGirl.create(:comment, :post => p)
|
||||
Timecop.travel(2.seconds.from_now) do
|
||||
c2 = FactoryGirl.create(:comment, :post => p)
|
||||
end
|
||||
p.reload
|
||||
assert_equal(c1.created_at.to_s, p.last_commented_at.to_s)
|
||||
end
|
||||
|
||||
@@ -21,8 +21,9 @@ class ForumPostTest < ActiveSupport::TestCase
|
||||
9.times do
|
||||
@posts << FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000))
|
||||
end
|
||||
sleep 2
|
||||
@posts << FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000))
|
||||
Timecop.travel(2.seconds.from_now) do
|
||||
@posts << FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000))
|
||||
end
|
||||
end
|
||||
|
||||
should "know which page it's on" do
|
||||
@@ -59,11 +60,12 @@ class ForumPostTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "update its parent when saved" do
|
||||
sleep 1
|
||||
original_topic_updated_at = @topic.updated_at
|
||||
Timecop.travel(1.second.from_now) do
|
||||
@original_topic_updated_at = @topic.updated_at
|
||||
end
|
||||
post = FactoryGirl.create(:forum_post, :topic_id => @topic.id)
|
||||
@topic.reload
|
||||
assert_not_equal(original_topic_updated_at, @topic.updated_at)
|
||||
assert_not_equal(@original_topic_updated_at, @topic.updated_at)
|
||||
end
|
||||
|
||||
should "be searchable by body content" do
|
||||
|
||||
Reference in New Issue
Block a user