@ar.overwrite @author
respond_to do |format|
if @ar.save
- format.html { redirect_to @ar, notice: 'Artist was successfully created.' }
+ format.html { redirect_to root_path, notice: 'Artist was successfully created.' }
format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
else
format.html { render action: "new" }
respond_to do |format|
if @ar.save
- format.html { redirect_to @ar, notice: 'Artist was successfully updated.' }
+ format.html { redirect_to '/home/configure', notice: 'Artist was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
@au.overwrite @user.id
respond_to do |format|
if @au.save
- format.html { redirect_to @au, notice: 'Author was successfully created.' }
+ format.html { redirect_to root_path, notice: 'Author was successfully created.' }
format.json { render json: @au.to_json(Author.show_json_opt), status: :created, location: @artist }
else
format.html { render action: "new" }
respond_to do |format|
if @au.save
- format.html { redirect_to @au, notice: 'Author was successfully updated.' }
+ format.html { redirect_to '/home/configure', notice: 'Author was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
end
def own? au
- return false unless au.is_a?(Author)
- self.author_id == au.id
+ if au.is_a?(Author)
+ self.author_id == au.id
+ elsif au.is_a?(Artist)
+ self.id == au.id
+ else
+ false
+ end
end
def visible? au
<p id="notice"><%= notice %></p>
<%= render 'form', :ar => @ar %>
-configure
-<%= link_to 'Show', @ar %> |
-<%= link_to 'Back', artists_path %>
<%= l @ar.updated_at %>
</p>
-<%= link_to t('link.back'), artists_path %>
+<% if @ar.own?(@artist) %>
+ <%= link_to t('link.edit'), edit_artist_path(@ar) %>
+<% end %>
<%= render 'form', :au => @au %>
-<%= link_to 'Show', @au %> |
-<%= link_to 'Back', authors_path %>
<%= l @au.updated_at %>
</p>
-<%= link_to t('link.back'), authors_path %>
+<% if @au.own?(@author) %>
+ <%= link_to t('link.edit'), edit_author_path(@au) %>
+<% end %>
<h1><%= t '.title' -%></h1>
+<p id="notice"><%= notice %></p>
<%= t('home.configure.caption', :email => @user.email) %>
<table class="no-border" width="100%">
Artist.should_receive(:show).exactly(1)
get :show
end
- it '@artistにアレを取得している' do
+ it '@arにアレを取得している' do
get :show, :id => @artist.id
- assigns(:artist).should eq(@artist)
+ assigns(:ar).should eq(@artist)
end
context 'html形式' do
it 'showテンプレートを描画する' do
end
end
context 'つつがなく終わるとき' do
- it "@artistに作成された絵師を保持していて、それがDBにある" do
+ it "@arに作成された絵師を保持していて、それがDBにある" do
post :create, :artist => @attr
- assigns(:artist).should be_a(Artist)
- assigns(:artist).should be_persisted
+ assigns(:ar).should be_a(Artist)
+ assigns(:ar).should be_persisted
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
post :create, :artist => @attr
response.status.should eq 302
end
- it '作成された絵師の表示ページへ遷移する' do
+ it 'トップページへ遷移する' do
# Artist.any_instance.stub(:save).and_return(true)
post :create, :artist => @attr
- response.should redirect_to(Artist.last)
+ response.should redirect_to(root_path)
end
end
context 'json形式' do
Artist.any_instance.should_receive(:save).exactly(1)
put :update, :id => @artist.id, :artist => @attr
end
- it '@artistにアレを取得している' do
+ it '@arにアレを取得している' do
put :update, :id => @artist.id, :artist => @attr
- assigns(:artist).should eq @artist
+ assigns(:ar).should eq @artist
end
end
context 'つつがなく終わるとき' do
put :update, :id => @artist.id, :artist => @attr
response.status.should eq 302
end
- it '更新された絵師の表示ページへ遷移する' do
+ it '設定ページへ遷移する' do
put :update, :id => @artist.id, :artist => @attr
- response.should redirect_to(@artist)
+ response.should redirect_to('/home/configure')
end
end
context 'json形式' do
post :create, :author => @attr
response.status.should eq 302
end
- it '作成された作家の表示ページへ遷移する' do
+ it 'トップページへ遷移する' do
# Author.any_instance.stub(:save).and_return(true)
post :create, :author => @attr
- response.should redirect_to(Author.last)
+ response.should redirect_to(root_path)
end
end
context 'json形式' do
put :update, :id => @author.id, :author => @attr
response.status.should eq 302
end
- it '更新された作家の表示ページへ遷移する' do
+ it '設定ページへ遷移する' do
put :update, :id => @author.id, :author => @attr
- response.should redirect_to(@author)
+ response.should redirect_to('/home/configure')
end
end
context 'json形式' do