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:
r888888888
2013-05-24 12:59:13 -07:00
parent 9dfb8aa33e
commit 4dff618863
17 changed files with 4877 additions and 4760 deletions

View File

@@ -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|

View File

@@ -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

View File

@@ -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?

View File

@@ -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 %>

View File

@@ -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? %>

View 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 %>