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:
@@ -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 %>
|
||||
Reference in New Issue
Block a user