From 305f415a00ff3da658a5ee77cf966e7f76f8230f Mon Sep 17 00:00:00 2001
From: yasushiito
diff --git a/app/views/authors/comics.html.erb b/app/views/authors/comics.html.erb
deleted file mode 100644
index 8aca58d1..00000000
--- a/app/views/authors/comics.html.erb
+++ /dev/null
@@ -1,28 +0,0 @@
-
- <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %>
- <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %>
- (<%= comic.stories.size -%>)
+ <%= link_to scroll_icon(:object => scroll, :size => 25), scroll_path(scroll) %>
+ <%= link_to h(truncate(scroll.title, :length => 40)), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %>
+ (<%= scroll.scroll_panels.size -%>)
- <%= distance_of_time_in_words_to_now comic.updated_at %>
+ <%= distance_of_time_in_words_to_now scroll.updated_at %>
- <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %>
- <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %>
+ <%= link_to author_icon(:object => scroll.author, :size => 25), scroll_path(scroll.author) %>
+ <%= link_to h(truncate(scroll.author.name, :length => 12)), author_path(scroll.author) %>
- <% if comic.own? author %>
- <%= link_to t('link.edit'), edit_comic_path(comic) %>
- <%= link_to t('link.destroy'), comic_path(comic), :method => :delete %>
+ <% if scroll.own? author %>
+ <%= link_to t('link.edit'), edit_scroll_path(scroll) %>
+ <%= link_to t('link.destroy'), scroll_path(scroll), :method => :delete %>
<% end %>
<%= t '.title' -%>
-
-
- <% @comics.each do |comic| %>
-
-<%= paginate(@paginate) %>
-<%= link_to t('comics.new.title'), new_comic_path %>
diff --git a/app/views/authors/scroll_panels.html.erb b/app/views/authors/scroll_panels.html.erb
new file mode 100644
index 00000000..3d75a57d
--- /dev/null
+++ b/app/views/authors/scroll_panels.html.erb
@@ -0,0 +1,9 @@
+
-
- <% end %>
-
- <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %>
- <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %>
- (<%= comic.stories.size -%>)
-
-
- <%= distance_of_time_in_words_to_now comic.updated_at %>
-
-
- <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %>
- <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %>
-
-
- <% if comic.own? @author %>
- <%= link_to t('link.edit'), edit_comic_path(comic) %>
- <%= link_to t('link.destroy'), comic_path(comic), :method => :delete %>
- <% end %>
-
- <%= t '.title' -%>
+
+
+ <% @scroll_panels.each do |scroll_panel| %>
+ <%= render 'scroll_panels/list_item', :scroll_panel => scroll_panel, :author => @author %>
+ <% end %>
+
+<%= paginate(@paginate) %>
+<%= link_to t('scroll_panels.new.title'), new_scroll_panel_path %>
diff --git a/app/views/authors/scrolls.html.erb b/app/views/authors/scrolls.html.erb
new file mode 100644
index 00000000..73db7bfe
--- /dev/null
+++ b/app/views/authors/scrolls.html.erb
@@ -0,0 +1,28 @@
+<%= t '.title' -%>
+
+
+ <% @scrolls.each do |scroll| %>
+
+<%= paginate(@paginate) %>
+<%= link_to t('scrolls.new.title'), new_scroll_path %>
diff --git a/app/views/authors/show.html.erb b/app/views/authors/show.html.erb
index aea2597a..9f2d3f2d 100644
--- a/app/views/authors/show.html.erb
+++ b/app/views/authors/show.html.erb
@@ -18,11 +18,11 @@
+
+ <% end %>
+
+ <%= link_to scroll_icon(:object => scroll, :size => 25), scroll_path(scroll) %>
+ <%= link_to h(truncate(scroll.title, :length => 40)), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %>
+ (<%= scroll.scroll_panels.size -%>)
+
+
+ <%= distance_of_time_in_words_to_now scroll.updated_at %>
+
+
+ <%= link_to author_icon(:object => scroll.author, :size => 25), scroll_path(scroll.author) %>
+ <%= link_to h(truncate(scroll.author.name, :length => 12)), author_path(scroll.author) %>
+
+
+ <% if scroll.own? @author %>
+ <%= link_to t('link.edit'), edit_scroll_path(scroll) %>
+ <%= link_to t('link.destroy'), scroll_path(scroll), :method => :delete %>
+ <% end %>
+
+
- <%= link_to t('authors.show.to_comics'), comics_author_path(@au) %> + <%= link_to t('authors.show.to_scrolls'), scrolls_author_path(@au) %>
- <%= link_to t('authors.show.to_stories'), stories_author_path(@au) %> + <%= link_to t('authors.show.to_scroll_panels'), scroll_panels_author_path(@au) %>
diff --git a/app/views/authors/stories.html.erb b/app/views/authors/stories.html.erb deleted file mode 100644 index a99f490f..00000000 --- a/app/views/authors/stories.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -
- <%= t_m 'Comic.id' -%>: - <%= h @comic.id %> -
- -- <%= t_m 'Comic.title' -%>: - <%= h @comic.title %> -
- -- <%= t_m 'Comic.visible' -%>: - <%= @comic.visible %> - <%= t_selected_item('comic_visible_items', @comic.visible) %> -
- -- <%= t_m 'Comic.author_id' -%>: - <%= @comic.author_id %> - <%= link_to h(@comic.author.name), browse_author_path(@comic.author) %> -
- -- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> -
- -- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> -
- -<%= link_to t('link.back'), :action => :list %> diff --git a/app/views/comics/edit.html.erb b/app/views/comics/edit.html.erb deleted file mode 100644 index 1d67f75e..00000000 --- a/app/views/comics/edit.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= notice %>
- -<%= render 'form' %> diff --git a/app/views/comics/edit.js.erb b/app/views/comics/edit.js.erb deleted file mode 100644 index ab2a7d24..00000000 --- a/app/views/comics/edit.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#newcomic").html("<%= escape_javascript(render('form')) -%>"); diff --git a/app/views/comics/index.atom.builder b/app/views/comics/index.atom.builder deleted file mode 100644 index a1e9b0c0..00000000 --- a/app/views/comics/index.atom.builder +++ /dev/null @@ -1,25 +0,0 @@ -atom_feed( - :language => 'ja-JP', - :root_url => root_url, - :url => root_url(:format => :atom), - :id => root_url -) do |feed| - feed.title MagicNumber['profile']['users']['caption'] - feed.subtitle sanitize(MagicNumber['profile']['users']['description'], :tags => %w(a p img br)) - feed.updated Time.now - feed.author {|author| author.name(MagicNumber['profile']['web_master'])} - - @comics.each do |comic| - feed.entry( - comic, - :url => comic_url(comic), - :id => comic_url(comic), - :published => comic.updated_at, - :updated => comic.updated_at - ) do |item| - item.title(comic.title) - item.content(comic.description, :type => 'html') - item.author {|author| author.name(comic.author.name)} - end - end -end diff --git a/app/views/comics/index.html.erb b/app/views/comics/index.html.erb deleted file mode 100644 index cef2ab93..00000000 --- a/app/views/comics/index.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<%= t_m 'Comic.id' -%> | -<%= t_m 'Comic.title' -%> | -<%= t_m 'Comic.visible' -%> | -<%= t_m 'Comic.author_id' -%> | -<%= t_m 'Comic.created_at' -%> | -<%= t_m 'Comic.updated_at' -%> | -
---|---|---|---|---|---|
<%= link_to comic.id, browse_comic_path(comic) %> | -<%= h(truncate(comic.title, :length => 12)) %> | -<%= comic.visible %> | -<%= link_to comic.author_id, browse_author_path(comic.author) %> | -<%= l comic.created_at %> | -<%= l comic.updated_at %> | -
<%= notice %>
- -- <%= t_m 'Comic.title' -%>: - <%= link_to h(@comic.title), :controller => 'stories', :action => :comic, :id => @comic.id %> -
- -- <%= t_m 'Comic.description' -%>: - <%= h(@comic.description) %> -
- -- <%= t_m 'Comic.visible' -%>: - <%= t_selected_item('comic_visible_items', @comic.visible) %> -
- -- <%= t_m 'Comic.author_id' -%>: - <%= link_to h(@comic.author.name), author_path(@comic.author) %> -
- -- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> -
- -- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> -
- -<%= link_to t('link.edit'), edit_comic_path(@comic) %> diff --git a/app/views/comics/show.rss.builder b/app/views/comics/show.rss.builder deleted file mode 100644 index 553f344f..00000000 --- a/app/views/comics/show.rss.builder +++ /dev/null @@ -1,24 +0,0 @@ -xml.instruct! - -xml.rss("version" => "2.0", - "xmlns:dc" => "http://purl.org/dc/elements/1.1/", - "xmlns:atom" => "http://www.w3.org/2005/Atom") do - xml.channel do - xml.title MagicNumber['profile']['users']['caption'] - xml.link root_url - xml.pubDate Time.now.rfc822 - xml.description sanitize(MagicNumber['profile']['users']['description'], :tags => %w(a p img br)) - xml.atom :link, "href" => @rss_url, "rel" => "self", "type" => "application/rss+xml" - - @comic.stories.each do |story| - xml.item do - xml.title story.panel.caption - xml.link panel_url(story.panel) - xml.guid panel_url(story.panel) - xml.description story.panel.plain_scenario - xml.pubDate story.panel.updated_at.to_formatted_s(:rfc822) - xml.dc :creator, story.panel.author.name - end - end - end -end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 392ac957..1f47cb16 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,14 +1,14 @@- <%= link_to t_m('Comic'), '/home/comics' %> + <%= link_to t_m('Scroll'), '/home/scrolls' %> | - <%= link_to t_m('Story'), '/home/stories' %> + <%= link_to t_m('ScrollPanel'), '/home/scroll_panels' %> |
<%= link_to t_m('Panel'), '/home/panels' %>
diff --git a/app/views/home/scroll_panels.html.erb b/app/views/home/scroll_panels.html.erb
index a99f490f..3d75a57d 100644
--- a/app/views/home/scroll_panels.html.erb
+++ b/app/views/home/scroll_panels.html.erb
@@ -1,9 +1,9 @@
<%= t '.title' -%><%= notice %>
<% if user_signed_in? %>
<%= link_to t('home.index.title'), '/home' %>
- <%= link_to t('home.comics.title'), '/home/comic' %>
+ <%= link_to t('home.scrolls.title'), '/home/scroll' %>
<%= link_to t('home.panels.title'), '/home/panel' %>
<%= link_to t('home.panel_pictures.title'), '/home/panel_picture' %>
<%= link_to h(truncate(@author.name, :length => 12)), main_app.author_path(@author) %>
@@ -41,8 +41,8 @@
user.resources
- <%= link_to 'comics', main_app.comics_path %>
- <%= link_to 'stories', main_app.new_story_path %>
+ <%= link_to 'scrolls', main_app.scrolls_path %>
+ <%= link_to 'scroll_panels', main_app.new_scroll_panel_path %>
<%= link_to 'panels', main_app.panels_path %>
<%= link_to 'original_pictures', main_app.original_pictures_path %>
<%= link_to 'resource_pictures', main_app.resource_pictures_path %>
diff --git a/app/views/layouts/test.html.erb b/app/views/layouts/test.html.erb
index 0f5cfcde..618f32cb 100644
--- a/app/views/layouts/test.html.erb
+++ b/app/views/layouts/test.html.erb
@@ -52,7 +52,7 @@
<%= link_to t('tab.reader.title'), '/' %>
- <%= link_to t_m('Comic'), main_app.comics_path %>
+ <%= link_to t_m('Scroll'), main_app.scrolls_path %>
<%= link_to t_m('Panel'), main_app.panels_path %>
<%= link_to t_m('ResourcePicture'), main_app.resource_pictures_path %>
<%= link_to t_m('SpeechBalloonTemplate'), main_app.speech_balloon_templates_path %>
@@ -63,7 +63,7 @@
<% if @author %>
<%= link_to t('tab.creator.home'), '/home' %>
- <%= link_to t('tab.creator.comic'), '/home/comics' %>
+ <%= link_to t('tab.creator.scroll'), '/home/scrolls' %>
<%= link_to t('tab.creator.panel'), '/home/panels' %>
<% if @artist %>
<%= link_to t('tab.creator.original_picture'), main_app.original_pictures_path %>
diff --git a/app/views/panels/_append_comic.html.erb b/app/views/panels/_append_comic.html.erb
deleted file mode 100644
index 2190d65c..00000000
--- a/app/views/panels/_append_comic.html.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-
- <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %>
- <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %>
- (<%= comic.stories.size -%>)
- |
-
- <%= distance_of_time_in_words_to_now comic.updated_at %>
- |
-
- <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %>
- <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %>
- |
-
- <% if comic.own? author %>
- <% @story = Story.new :comic_id => comic.id, :panel_id => panel.id %>
- <%= form_for(@story) do |f| %>
- <%= f.hidden_field :comic_id %>
- <%= f.hidden_field :t %>
- <%= f.hidden_field :panel_id %>
- |
-
- <%= f.submit t('panels.show.append') %>
-
- <% end %>
- <% end %>
-
- <%= h(truncate(comic.description, :length => 40)) %>
- |
-
+ <%= link_to scroll_icon(:object => scroll, :size => 25), scroll_path(scroll) %>
+ <%= link_to h(truncate(scroll.title, :length => 40)), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %>
+ (<%= scroll.scroll_panels.size -%>)
+ |
+
+ <%= distance_of_time_in_words_to_now scroll.updated_at %>
+ |
+
+ <%= link_to author_icon(:object => scroll.author, :size => 25), scroll_path(scroll.author) %>
+ <%= link_to h(truncate(scroll.author.name, :length => 12)), author_path(scroll.author) %>
+ |
+
+ <% if scroll.own? author %>
+ <% @scroll_panel = ScrollPanel.new :scroll_id => scroll.id, :panel_id => panel.id %>
+ <%= form_for(@scroll_panel) do |f| %>
+ <%= f.hidden_field :scroll_id %>
+ <%= f.hidden_field :t %>
+ <%= f.hidden_field :panel_id %>
+ |
+
+ <%= f.submit t('panels.show.append') %>
+
+ <% end %>
+ <% end %>
+
+ <%= h(truncate(scroll.description, :length => 40)) %>
+ |
+<%= t('panels.show.new_comics') -%>+<%= t('panels.show.new_scrolls') -%><%= t('panels.show.fresh_comics') -%>+<%= t('panels.show.fresh_scrolls') -%><%= t('panels.show.copy') -%>diff --git a/app/views/scroll_panels/_append_panel.html.erb b/app/views/scroll_panels/_append_panel.html.erb index 241bcf84..a7d84bce 100644 --- a/app/views/scroll_panels/_append_panel.html.erb +++ b/app/views/scroll_panels/_append_panel.html.erb @@ -4,18 +4,18 @@ <%= link_to author_icon(:object => panel.author, :size => 17), author_path(panel.author) %> |
- <%= link_to h(truncate(h(panel.caption), :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %> + <%= link_to h(truncate(h(panel.caption), :length => 40)), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %> | <%= l panel.updated_at %> | - <% @story = Story.new :comic_id => comic.id, :panel_id => panel.id -%> - <%= form_for(@story) do |f| %> - <%= f.hidden_field :comic_id %> + <% @scroll_panel = ScrollPanel.new :scroll_id => scroll.id, :panel_id => panel.id -%> + <%= form_for(@scroll_panel) do |f| %> + <%= f.hidden_field :scroll_id %> <%= f.hidden_field :t %> <%= f.hidden_field :panel_id %> - <%= f.submit t('stories.comic.append') %> + <%= f.submit t('scroll_panels.scroll.append') %> <% end %> |
- <% if story.panel -%> - <%= link_to panel_icon(:object => story.panel, :size => 25), panel_path(story.panel) %> - <%= link_to author_icon(:object => story.panel.author, :size => 17), author_path(story.panel.author) %> - <%= distance_of_time_in_words_to_now story.panel.updated_at %> + <% if scroll_panel.panel -%> + <%= link_to panel_icon(:object => scroll_panel.panel, :size => 25), panel_path(scroll_panel.panel) %> + <%= link_to author_icon(:object => scroll_panel.panel.author, :size => 17), author_path(scroll_panel.panel.author) %> + <%= distance_of_time_in_words_to_now scroll_panel.panel.updated_at %> <% end %> | - <%= link_to story_icon(:object => story, :size => 25), story_path(story) %> - <%= link_to author_icon(:object => story.author, :size => 17), author_path(story.author) %> - <%= l story.updated_at %> + <%= link_to scroll_panel_icon(:object => scroll_panel, :size => 25), scroll_panel_path(scroll_panel) %> + <%= link_to author_icon(:object => scroll_panel.author, :size => 17), author_path(scroll_panel.author) %> + <%= l scroll_panel.updated_at %> | - <% if story.own? author %> - <%= render 'order', :story => story %> + <% if scroll_panel.own? author %> + <%= render 'order', :scroll_panel => scroll_panel %> <% else %> - No.<%= story.t %> + No.<%= scroll_panel.t %> <% end %> | ||||||||||||
- <%= link_to comic_icon(:object => story.comic, :size => 25), comic_path(story.comic) %> + <%= link_to scroll_icon(:object => scroll_panel.scroll, :size => 25), scroll_path(scroll_panel.scroll) %> | - <%= link_to h(story.comic.title), :controller => 'stories', :action => :comic, :id => story.comic.id %> + <%= link_to h(scroll_panel.scroll.title), :controller => 'scroll_panels', :action => :scroll, :id => scroll_panel.scroll.id %> | - <%= link_to author_icon(:object => story.comic.author, :size => 17), author_path(story.comic.author) %> + <%= link_to author_icon(:object => scroll_panel.scroll.author, :size => 17), author_path(scroll_panel.scroll.author) %> | - <%= link_to story_icon(:object => story, :size => 25), story_path(story) %> + <%= link_to scroll_panel_icon(:object => scroll_panel, :size => 25), scroll_panel_path(scroll_panel) %> | - <%= link_to author_icon(:object => story.author, :size => 17), author_path(story.author) %> + <%= link_to author_icon(:object => scroll_panel.author, :size => 17), author_path(scroll_panel.author) %> | - No.<%= story.t %> + No.<%= scroll_panel.t %> | - <%= l story.updated_at %> + <%= l scroll_panel.updated_at %> | - <% if story.panel %> - <%= h story.panel.caption %> + <% if scroll_panel.panel %> + <%= h scroll_panel.panel.caption %> <% end %> |
No. <%= f.number_field :t, :size => 3 %> <%= f.hidden_field :panel_id %> - <%= f.hidden_field :comic_id %> + <%= f.hidden_field :scroll_id %> | - <%= f.submit t 'stories.move' %> + <%= f.submit t 'scroll_panels.move' %> |
- <%= t_m 'Comic.visible' -%>: - <%= t_selected_item('comic_visible_items', @comic.visible) %> + <%= t_m 'Scroll.visible' -%>: + <%= t_selected_item('scroll_visible_items', @scroll.visible) %>
<% end %>- <%= t_m 'Comic.author_id' -%>: - <%= link_to h(@comic.author.name), author_path(@comic.author) %> + <%= t_m 'Scroll.author_id' -%>: + <%= link_to h(@scroll.author.name), author_path(@scroll.author) %>
- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> + <%= t_m 'Scroll.created_at' -%>: + <%= l @scroll.created_at %>
- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> + <%= t_m 'Scroll.updated_at' -%>: + <%= l @scroll.updated_at %>
diff --git a/app/views/scroll_panels/browse.html.erb b/app/views/scroll_panels/browse.html.erb index 24a7a6ca..b4083f67 100644 --- a/app/views/scroll_panels/browse.html.erb +++ b/app/views/scroll_panels/browse.html.erb @@ -1,28 +1,28 @@<%= notice %>
- comic_id: - <%= @story.comic_id %> + scroll_id: + <%= @scroll_panel.scroll_id %>
panel_id: - <%= @story.panel_id %> + <%= @scroll_panel.panel_id %>
t: - <%= @story.t %> + <%= @scroll_panel.t %>
author_id: - <%= @story.author_id %> + <%= @scroll_panel.author_id %>
updated_at: - <%= @story.updated_at %> + <%= @scroll_panel.updated_at %>
<%= link_to 'Back', :action => :list %> diff --git a/app/views/scroll_panels/edit.html.erb b/app/views/scroll_panels/edit.html.erb index cee9463d..91bdcac0 100644 --- a/app/views/scroll_panels/edit.html.erb +++ b/app/views/scroll_panels/edit.html.erb @@ -2,4 +2,4 @@<%= notice %>
<%= render 'form' %> -<%= button_to 'Destroy', @story.panel, confirm: 'Are you sure?', method: :delete %> +<%= button_to 'Destroy', @scroll_panel.panel, confirm: 'Are you sure?', method: :delete %> diff --git a/app/views/scroll_panels/edit.js.erb b/app/views/scroll_panels/edit.js.erb index 29c687f7..65bc52a8 100644 --- a/app/views/scroll_panels/edit.js.erb +++ b/app/views/scroll_panels/edit.js.erb @@ -1 +1 @@ -$("#story-update-<%= @story.id -%>").html("<%= escape_javascript(render('editform')) -%>"); +$("#scroll_panel-update-<%= @scroll_panel.id -%>").html("<%= escape_javascript(render('editform')) -%>"); diff --git a/app/views/scroll_panels/index.html.erb b/app/views/scroll_panels/index.html.erb index 7b61ab84..74213ffd 100644 --- a/app/views/scroll_panels/index.html.erb +++ b/app/views/scroll_panels/index.html.erb @@ -1,8 +1,8 @@id | -comic_id | +scroll_id | panel_id | t | author_id | @@ -12,15 +12,15 @@|||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<%= link_to story.id, :action => :browse, :id => story.id %> | -<%= story.comic_id %> | -<%= story.panel_id %> | -<%= story.t %> | -<%= link_to story.author_id, :controller => '/authors', :action => :browse, :id => story.author_id %> | -<%= story.created_at %> | -<%= story.updated_at %> | +<%= link_to scroll_panel.id, :action => :browse, :id => scroll_panel.id %> | +<%= scroll_panel.scroll_id %> | +<%= scroll_panel.panel_id %> | +<%= scroll_panel.t %> | +<%= link_to scroll_panel.author_id, :controller => '/authors', :action => :browse, :id => scroll_panel.author_id %> | +<%= scroll_panel.created_at %> | +<%= scroll_panel.updated_at %> |
<%= notice %>
- <%= t_m 'Story.comic_id' -%>: - <%= link_to comic_icon(:object => @story.comic), comic_path(@story.comic) %> - <%= link_to h(@story.comic.title), :controller => 'stories', :action => :comic, :id => @story.comic.id %> + <%= t_m 'ScrollPanel.scroll_id' -%>: + <%= link_to scroll_icon(:object => @scroll_panel.scroll), scroll_path(@scroll_panel.scroll) %> + <%= link_to h(@scroll_panel.scroll.title), :controller => 'scroll_panels', :action => :scroll, :id => @scroll_panel.scroll.id %>
- <%= t_m 'Story.panel_id' -%>: - <%= link_to panel_icon(:object => @story.panel), panel_path(@story.panel) %> + <%= t_m 'ScrollPanel.panel_id' -%>: + <%= link_to panel_icon(:object => @scroll_panel.panel), panel_path(@scroll_panel.panel) %>
- <%= t_m 'Story.t' -%>: - <%= @story.t %> + <%= t_m 'ScrollPanel.t' -%>: + <%= @scroll_panel.t %>
- <%= t_m 'Story.author_id' -%>: - <%= link_to author_icon(:object => @story.author), author_path(@story.author) %> - <%= link_to h(@story.author.name), author_path(@story.author) %> + <%= t_m 'ScrollPanel.author_id' -%>: + <%= link_to author_icon(:object => @scroll_panel.author), author_path(@scroll_panel.author) %> + <%= link_to h(@scroll_panel.author.name), author_path(@scroll_panel.author) %>
- <%= t_m 'Story.created_at' -%>: - <%= l @story.created_at %> + <%= t_m 'ScrollPanel.created_at' -%>: + <%= l @scroll_panel.created_at %>
- <%= t_m 'Story.updated_at' -%>: - <%= l @story.updated_at %> + <%= t_m 'ScrollPanel.updated_at' -%>: + <%= l @scroll_panel.updated_at %>
-<% if @story.own? @author -%> - <%= link_to t('link.edit'), edit_story_path(@story) %> - <%= link_to t('link.destroy'), story_path(@story), :method => :delete %> +<% if @scroll_panel.own? @author -%> + <%= link_to t('link.edit'), edit_scroll_panel_path(@scroll_panel) %> + <%= link_to t('link.destroy'), scroll_panel_path(@scroll_panel), :method => :delete %> <% end %>- <%= t_m 'Comic.id' -%>: - <%= h @comic.id %> + <%= t_m 'Scroll.id' -%>: + <%= h @scroll.id %>
- <%= t_m 'Comic.title' -%>: - <%= h @comic.title %> + <%= t_m 'Scroll.title' -%>: + <%= h @scroll.title %>
- <%= t_m 'Comic.visible' -%>: - <%= @comic.visible %> - <%= t_selected_item('comic_visible_items', @comic.visible) %> + <%= t_m 'Scroll.visible' -%>: + <%= @scroll.visible %> + <%= t_selected_item('scroll_visible_items', @scroll.visible) %>
- <%= t_m 'Comic.author_id' -%>: - <%= @comic.author_id %> - <%= link_to h(@comic.author.name), browse_author_path(@comic.author) %> + <%= t_m 'Scroll.author_id' -%>: + <%= @scroll.author_id %> + <%= link_to h(@scroll.author.name), browse_author_path(@scroll.author) %>
- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> + <%= t_m 'Scroll.created_at' -%>: + <%= l @scroll.created_at %>
- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> + <%= t_m 'Scroll.updated_at' -%>: + <%= l @scroll.updated_at %>
<%= link_to t('link.back'), :action => :list %> diff --git a/app/views/scrolls/edit.js.erb b/app/views/scrolls/edit.js.erb index ab2a7d24..830c4f59 100644 --- a/app/views/scrolls/edit.js.erb +++ b/app/views/scrolls/edit.js.erb @@ -1 +1 @@ -$("#newcomic").html("<%= escape_javascript(render('form')) -%>"); +$("#newscroll").html("<%= escape_javascript(render('form')) -%>"); diff --git a/app/views/scrolls/index.html.erb b/app/views/scrolls/index.html.erb index cef2ab93..df40c94c 100644 --- a/app/views/scrolls/index.html.erb +++ b/app/views/scrolls/index.html.erb @@ -1,9 +1,9 @@<%= t_m 'Comic.id' -%> | -<%= t_m 'Comic.title' -%> | -<%= t_m 'Comic.visible' -%> | -<%= t_m 'Comic.author_id' -%> | -<%= t_m 'Comic.created_at' -%> | -<%= t_m 'Comic.updated_at' -%> | +<%= t_m 'Scroll.id' -%> | +<%= t_m 'Scroll.title' -%> | +<%= t_m 'Scroll.visible' -%> | +<%= t_m 'Scroll.author_id' -%> | +<%= t_m 'Scroll.created_at' -%> | +<%= t_m 'Scroll.updated_at' -%> |
---|---|---|---|---|---|---|---|---|---|---|---|
<%= link_to comic.id, browse_comic_path(comic) %> | -<%= h(truncate(comic.title, :length => 12)) %> | -<%= comic.visible %> | -<%= link_to comic.author_id, browse_author_path(comic.author) %> | -<%= l comic.created_at %> | -<%= l comic.updated_at %> | +<%= link_to scroll.id, browse_scroll_path(scroll) %> | +<%= h(truncate(scroll.title, :length => 12)) %> | +<%= scroll.visible %> | +<%= link_to scroll.author_id, browse_author_path(scroll.author) %> | +<%= l scroll.created_at %> | +<%= l scroll.updated_at %> |
<%= notice %>
- <%= t_m 'Comic.title' -%>: - <%= link_to h(@comic.title), :controller => 'stories', :action => :comic, :id => @comic.id %> + <%= t_m 'Scroll.title' -%>: + <%= link_to h(@scroll.title), :controller => 'scroll_panels', :action => :scroll, :id => @scroll.id %>
- <%= t_m 'Comic.description' -%>: - <%= h(@comic.description) %> + <%= t_m 'Scroll.description' -%>: + <%= h(@scroll.description) %>
- <%= t_m 'Comic.visible' -%>: - <%= t_selected_item('comic_visible_items', @comic.visible) %> + <%= t_m 'Scroll.visible' -%>: + <%= t_selected_item('scroll_visible_items', @scroll.visible) %>
- <%= t_m 'Comic.author_id' -%>: - <%= link_to h(@comic.author.name), author_path(@comic.author) %> + <%= t_m 'Scroll.author_id' -%>: + <%= link_to h(@scroll.author.name), author_path(@scroll.author) %>
- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> + <%= t_m 'Scroll.created_at' -%>: + <%= l @scroll.created_at %>
- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> + <%= t_m 'Scroll.updated_at' -%>: + <%= l @scroll.updated_at %>
-<%= link_to t('link.edit'), edit_comic_path(@comic) %> +<%= link_to t('link.edit'), edit_scroll_path(@scroll) %> diff --git a/app/views/stories/_append_panel.html.erb b/app/views/stories/_append_panel.html.erb deleted file mode 100644 index 241bcf84..00000000 --- a/app/views/stories/_append_panel.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -- <%= t_m 'Comic.visible' -%>: - <%= t_selected_item('comic_visible_items', @comic.visible) %> -
-<% end %> - -- <%= t_m 'Comic.author_id' -%>: - <%= link_to h(@comic.author.name), author_path(@comic.author) %> -
- -- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> -
- -- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> -
- diff --git a/app/views/stories/_footer.html.erb b/app/views/stories/_footer.html.erb deleted file mode 100644 index 56e93674..00000000 --- a/app/views/stories/_footer.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -- <% if story.panel -%> - <%= link_to panel_icon(:object => story.panel, :size => 25), panel_path(story.panel) %> - <%= link_to author_icon(:object => story.panel.author, :size => 17), author_path(story.panel.author) %> - <%= distance_of_time_in_words_to_now story.panel.updated_at %> - <% end %> - | -- <%= link_to story_icon(:object => story, :size => 25), story_path(story) %> - <%= link_to author_icon(:object => story.author, :size => 17), author_path(story.author) %> - <%= l story.updated_at %> - | -- <% if story.own? author %> - <%= render 'order', :story => story %> - <% else %> - No.<%= story.t %> - <% end %> - | -
- <%= link_to(tag(:img, picture.tmb_opt_img_tag), picture_path(picture.id)) -%> - | -- <%= render picture.credit_template, :picture => picture %> - | -
- No. - <%= f.number_field :t, :size => 3 %> - <%= f.hidden_field :panel_id %> - <%= f.hidden_field :comic_id %> - | -- <%= f.submit t 'stories.move' %> - | -
<%= notice %>
- -- comic_id: - <%= @story.comic_id %> -
- -- panel_id: - <%= @story.panel_id %> -
- -- t: - <%= @story.t %> -
- -- author_id: - <%= @story.author_id %> -
- -- updated_at: - <%= @story.updated_at %> -
- -<%= link_to 'Back', :action => :list %> diff --git a/app/views/stories/comic.html.erb b/app/views/stories/comic.html.erb deleted file mode 100644 index 631f6f03..00000000 --- a/app/views/stories/comic.html.erb +++ /dev/null @@ -1,33 +0,0 @@ -<% @page_title = @comic.title %> -<%= notice %>
-<%= render 'comic_header', :comic => @comic, :author => @author %> - -<% if @stories.empty? -%> -<%= notice %>
- -<%= render 'form' %> -<%= button_to 'Destroy', @story.panel, confirm: 'Are you sure?', method: :delete %> diff --git a/app/views/stories/edit.js.erb b/app/views/stories/edit.js.erb deleted file mode 100644 index 29c687f7..00000000 --- a/app/views/stories/edit.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#story-update-<%= @story.id -%>").html("<%= escape_javascript(render('editform')) -%>"); diff --git a/app/views/stories/index.html.erb b/app/views/stories/index.html.erb deleted file mode 100644 index 7b61ab84..00000000 --- a/app/views/stories/index.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -id | -comic_id | -panel_id | -t | -author_id | -created_at | -updated_at | -- |
---|---|---|---|---|---|---|---|
<%= link_to story.id, :action => :browse, :id => story.id %> | -<%= story.comic_id %> | -<%= story.panel_id %> | -<%= story.t %> | -<%= link_to story.author_id, :controller => '/authors', :action => :browse, :id => story.author_id %> | -<%= story.created_at %> | -<%= story.updated_at %> | -- | -
<%= notice %>
- -- <%= t_m 'Story.comic_id' -%>: - <%= link_to comic_icon(:object => @story.comic), comic_path(@story.comic) %> - <%= link_to h(@story.comic.title), :controller => 'stories', :action => :comic, :id => @story.comic.id %> -
- -- <%= t_m 'Story.panel_id' -%>: - <%= link_to panel_icon(:object => @story.panel), panel_path(@story.panel) %> -
- -- <%= t_m 'Story.t' -%>: - <%= @story.t %> -
- -- <%= t_m 'Story.author_id' -%>: - <%= link_to author_icon(:object => @story.author), author_path(@story.author) %> - <%= link_to h(@story.author.name), author_path(@story.author) %> -
- -- <%= t_m 'Story.created_at' -%>: - <%= l @story.created_at %> -
- -- <%= t_m 'Story.updated_at' -%>: - <%= l @story.updated_at %> -
-<% if @story.own? @author -%> - <%= link_to t('link.edit'), edit_story_path(@story) %> - <%= link_to t('link.destroy'), story_path(@story), :method => :delete %> -<% end %> - -- <%= link_to 'comics', :controller => 'comics', :action => :list %> + <%= link_to 'scrolls', :controller => 'scrolls', :action => :list %> | ||
- <%= link_to 'stories', :controller => 'stories', :action => :list %> + <%= link_to 'scroll_panels', :controller => 'scroll_panels', :action => :list %> | ||
- <%= link_to t_m('Comic'), main_app.comics_path %> + <%= link_to t_m('Scroll'), main_app.scrolls_path %> | - <%= link_to t_m('Story'), main_app.stories_path %> + <%= link_to t_m('ScrollPanel'), main_app.scroll_panels_path %> | <%= link_to t_m('Panel'), main_app.panels_path %> diff --git a/config/locales/pettanr.ja.yml b/config/locales/pettanr.ja.yml index 42eef606..ad5340d4 100644 --- a/config/locales/pettanr.ja.yml +++ b/config/locales/pettanr.ja.yml @@ -18,8 +18,8 @@ ja: user: ã¦ã¼ã¶ admin: 管çè demand_user: åæ - comic: ã³ãã㯠- story: ã¹ãã¼ãªã¼ + scroll: ã³ãã㯠+ scroll_panel: ã¹ãã¼ãªã¼ panel: ã³ã panel_picture: ã³ãçµµ speech_balloon: ãããã· @@ -67,15 +67,15 @@ ja: current_password: ç¾å¨ã®ãã¹ã¯ã¼ã remember_me: 次åããèªåã§ãã°ã¤ã³ authentication_token: èªè¨¼ãã¼ã¯ã³ - comic: + scroll: title: ã¿ã¤ãã« description: ãããã visible: å ¬é author_id: ä½å®¶ created_at: æ´æ° updated_at: ä½æ - story: - comic_id: ã³ãã㯠+ scroll_panel: + scroll_id: ã³ãã㯠panel_id: ã³ã author_id: ç·¨éè t: No. @@ -314,7 +314,7 @@ ja: picture_io: error: ç»åä¿ç®¡åº«ã¨ã®æç¶ãã§ç°å¸¸ãçºçãã¾ããã select_items: - comic: + scroll: visible: private: éå ¬é public: å ¬é @@ -405,15 +405,15 @@ ja: home: index: title: ãã¼ã - updated_comic: æè¿æ´æ°ããæ¼«ç» + updated_scroll: æè¿æ´æ°ããæ¼«ç» catch: ã¤ããã§ããã³ã used_element: æè¿ä½¿ã£ãé¨å updated_picture: æè¿æ´æ°ããç»å artist: 絵師 not_artist: ç»åãå ¬éããã«ã¯çµµå¸«ç»é² - comics: + scrolls: title: æè¿æ´æ°ããã³ãã㯠- stories: + scroll_panels: title: æè¿æ´æ°ããã¹ãã¼ãªã¼ panels: title: æè¿æ´æ°ããã³ã @@ -458,7 +458,7 @@ ja: human_resources: 人ç©ãã system_resources: ã·ã¹ãã ãªã½ã¼ã¹ãã return: ã·ã³ãã«çã«æ»ã - comics: + scrolls: index: title: ã³ããã¯ä¸è¦§ new: æ°å @@ -478,7 +478,7 @@ ja: title: ã³ãã㯠çä¸è¦§ browse: title: ã³ãã㯠çå票 - stories: + scroll_panels: index: title: ã¹ãã¼ãªã¼ä¸è¦§ show: @@ -493,7 +493,7 @@ ja: title: 並ã³æ¿ã destroy: title: ã¹ãã¼ãªã¼åé¤ - comic: + scroll: title: ã³ããã¯ãèªã empty: ã¹ãã¼ãªã¼ã¯ããã¾ãã append: ãã®ã³ãã追å ãã @@ -509,8 +509,8 @@ ja: show: title: ã³ã詳細 append: ãã®ã³ããã¯ã«è¿½å ãã - new_comics: æè¿ä½æããã³ãã㯠- fresh_comics: æè¿æ´æ°ããã³ãã㯠+ new_scrolls: æè¿ä½æããã³ãã㯠+ fresh_scrolls: æè¿æ´æ°ããã³ãã㯠copy: ã³ããã³ãã¼ããã inspire: ã¤ã³ã¹ãã¤ã¤ new: @@ -755,16 +755,16 @@ ja: title: ä½å®¶ä¸è¦§ show: title: ä½å®¶è©³ç´° - to_comics: æè¿æ´æ°ããã³ãã㯠- to_stories: æè¿æ´æ°ããã¹ãã¼ãªã¼ + to_scrolls: æè¿æ´æ°ããã³ãã㯠+ to_scroll_panels: æè¿æ´æ°ããã¹ãã¼ãªã¼ to_panels: æè¿æ´æ°ããã³ã to_panel_pictures: æè¿ã³ãã§ä½¿ã£ãã³ãçµµ to_speech_balloons: æè¿æ´æ°ãããããã· to_ground_pictures: æè¿ã³ãã§ä½¿ã£ãçµµå° to_ground_colors: æè¿ã³ãã§ä½¿ã£ãè²å° - comics: + scrolls: title: æè¿æ´æ°ããã³ãã㯠- stories: + scroll_panels: title: æè¿æ´æ°ããã¹ãã¼ãªã¼ panels: title: æè¿æ´æ°ããã³ã @@ -992,7 +992,7 @@ ja: tab: creator: home: ä½ãã»è¦ãã - comic: ã³ãã㯠+ scroll: ã³ãã㯠panel: ã³ã original_picture: åç» resource_picture: ç´ æ diff --git a/config/magic_number.yml b/config/magic_number.yml index e9037f67..a0619918 100644 --- a/config/magic_number.yml +++ b/config/magic_number.yml @@ -6,9 +6,9 @@ provider_status_status_items: [['select_items.provider_status.status.waiting', 0], ['select_items.provider_status.status.receiving', 1]] demander_status_status_items: [['select_items.demander_status.status.waiting', 0], ['select_items.demander_status.status.rejected', 1], ['select_items.demander_status.status.requesting', 2], ['select_items.demander_status.status.approved', 3]] - comic_visible_items: [ - ['select_items.comic.visible.private', 0], - ['select_items.comic.visible.public', 1] + scroll_visible_items: [ + ['select_items.scroll.visible.private', 0], + ['select_items.scroll.visible.public', 1] ] panel_visible_items: [ ['select_items.panel.visible.private', 0], diff --git a/config/routes.rb b/config/routes.rb index ec569e81..6bfe6691 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,42 +55,6 @@ Pettanr::Application.routes.draw do get :resource_pictures end end - resources :comics do - new do - get :new - end - collection do - get :index - get :show - get :count - post :create - get :list - end - member do - get :edit - put :update - delete :destroy - get :browse - end - end - resources :stories do - new do - get :new - end - collection do - get :index - get :show - post :create - get :list - end - member do - get :edit - get :comic - put :update - delete :destroy - get :browse - end - end resources :scrolls do new do get :new diff --git a/db/migrate/20130911043458_copy_to_scroll.rb b/db/migrate/20130911043458_copy_to_scroll.rb new file mode 100644 index 00000000..fe977c8f --- /dev/null +++ b/db/migrate/20130911043458_copy_to_scroll.rb @@ -0,0 +1,20 @@ +require Rails.root + 'config/environment' +class CopyToScroll < ActiveRecord::Migration + def up + ::Comic.find(:all).each do |i| + attr = i.attributes + attr.delete 'id' + ::Scroll.create! attr + end + ::Story.find(:all).each do |i| + attr = i.attributes + attr.delete 'id' + attr['scroll_id'] = attr['comic_id'] + attr.delete 'comic_id' + ::ScrollPanel.create! attr + end + end + + def down + end +end diff --git a/spec/controllers/authors_controller_spec.rb b/spec/controllers/authors_controller_spec.rb index d058db12..53728ca2 100644 --- a/spec/controllers/authors_controller_spec.rb +++ b/spec/controllers/authors_controller_spec.rb @@ -249,80 +249,80 @@ if MagicNumber['run_mode'] == 1 @other_user = FactoryGirl.create( :user_yas) @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id + @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id Author.stub(:show).and_return(@other_author) - Comic.stub(:himlist).and_return([@comic, @comic, @comic]) + Scroll.stub(:himlist).and_return([@scroll, @scroll, @scroll]) sign_in @user end context 'ãã©ã¡ã¼ã¿pageã«ã¤ãã¦' do it '@pageã«å¤ãå ¥ã' do - get :comics, :id => @other_author.id, :page => 5 + get :scrolls, :id => @other_author.id, :page => 5 assigns(:page).should eq 5 end it 'çç¥ãããã¨@pageã«1å¤ãå ¥ã' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id assigns(:page).should eq 1 end it 'ä¸ããããpage_sizeãã»ããããã¦ãã' do - get :comics, :id => @other_author.id, :page_size => 15 + get :scrolls, :id => @other_author.id, :page_size => 15 assigns(:page_size).should eq 15 end it 'çç¥ãããã¨@page_sizeã«ããã©ã«ãå¤ãå ¥ã' do - get :comics, :id => @other_author.id - assigns(:page_size).should eq Author.default_comic_page_size + get :scrolls, :id => @other_author.id + assigns(:page_size).should eq Author.default_scroll_page_size end it 'æ大ãè¶ ããã¨@page_sizeã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :comics, :id => @other_author.id, :page_size => 1500 - assigns(:page_size).should eq Author.comic_max_page_size + get :scrolls, :id => @other_author.id, :page_size => 1500 + assigns(:page_size).should eq Author.scroll_max_page_size end it 'ä¸æ£ãªå¤ãå ¥ãã¨@page_sizeã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :comics, :id => @other_author.id, :page_size => 0 - assigns(:page_size).should eq Author.default_comic_page_size + get :scrolls, :id => @other_author.id, :page_size => 0 + assigns(:page_size).should eq Author.default_scroll_page_size end end context 'ã¤ã¤ããªãçµããã¨ã' do it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end it 'ä½å®¶ã¢ãã«ã«åä½åå¾ãåãåããã¦ãã' do Author.should_receive(:show).exactly(1) - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id end it 'ã³ããã¯ã¢ãã«ã«ä¸è¦§ãåãåããã¦ãã' do - Comic.should_receive(:himlist).exactly(1) - get :comics, :id => @other_author.id + Scroll.should_receive(:himlist).exactly(1) + get :scrolls, :id => @other_author.id end - it '@comicsã«ãªã¹ããåå¾ãã¦ãã' do - get :comics, :id => @other_author.id - assigns(:comics).should have_at_least(3).items + it '@scrollsã«ãªã¹ããåå¾ãã¦ãã' do + get :scrolls, :id => @other_author.id + assigns(:scrolls).should have_at_least(3).items end context 'htmlå½¢å¼' do it '@paginateã«ãã¼ã¸å¶å¾¡ãåå¾ãã¦ãã' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true end - it 'comicsãã³ãã¬ã¼ããæç»ãã' do - get :comics, :id => @other_author.id - response.should render_template("comics") + it 'scrollsãã³ãã¬ã¼ããæç»ãã' do + get :scrolls, :id => @other_author.id + response.should render_template("scrolls") end end context 'jsonå½¢å¼' do it 'jsonãã¼ã¿ãè¿ã' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end it 'ã³ããã¯ã¢ãã«ã«jsonä¸è¦§åºåãªãã·ã§ã³ãåãåããã¦ãã' do - Comic.should_receive(:list_json_opt).exactly(1) - get :comics, :id => @other_author.id, :format => :json + Scroll.should_receive(:list_json_opt).exactly(1) + get :scrolls, :id => @other_author.id, :format => :json end it 'ãã¼ã¿ããªã¹ãæ§é ã«ãªã£ã¦ãã' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json json = JSON.parse response.body json.should have_at_least(3).items end it 'ãªã¹ãã®å é ãããã¯ã³ããã¯ã£ã½ããã®ã§ãã£ã¦æ¬²ãã' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json json = JSON.parse response.body json.first.has_key?("title").should be_true json.first.has_key?("visible").should be_true @@ -335,21 +335,21 @@ if MagicNumber['run_mode'] == 1 end context 'htmlå½¢å¼' do it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.status.should eq 302 end it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should redirect_to '/users/sign_in' end end context 'jsonå½¢å¼' do it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json response.status.should eq 401 end it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json response.message.should match(/Unauthorized/) end end @@ -360,7 +360,7 @@ if MagicNumber['run_mode'] == 1 sign_in @admin end it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end end @@ -369,7 +369,7 @@ if MagicNumber['run_mode'] == 1 @author.destroy end it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end end @@ -380,85 +380,85 @@ if MagicNumber['run_mode'] == 1 @other_user = FactoryGirl.create( :user_yas) @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id + @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_user.author.id + @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_user.author.id Author.stub(:show).and_return(@other_author) - Story.stub(:himlist).and_return([@story, @story, @story]) + ScrollPanel.stub(:himlist).and_return([@scroll_panel, @scroll_panel, @scroll_panel]) sign_in @user end context 'ãã©ã¡ã¼ã¿pageã«ã¤ãã¦' do it '@pageã«å¤ãå ¥ã' do - get :stories, :id => @other_author.id, :page => 5 + get :scroll_panels, :id => @other_author.id, :page => 5 assigns(:page).should eq 5 end it 'çç¥ãããã¨@pageã«1å¤ãå ¥ã' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id assigns(:page).should eq 1 end it 'ä¸ããããpage_sizeãã»ããããã¦ãã' do - get :stories, :id => @other_author.id, :page_size => 15 + get :scroll_panels, :id => @other_author.id, :page_size => 15 assigns(:page_size).should eq 15 end it 'çç¥ãããã¨@page_sizeã«ããã©ã«ãå¤ãå ¥ã' do - get :stories, :id => @other_author.id - assigns(:page_size).should eq Author.default_story_page_size + get :scroll_panels, :id => @other_author.id + assigns(:page_size).should eq Author.default_scroll_panel_page_size end it 'æ大ãè¶ ããã¨@page_sizeã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :stories, :id => @other_author.id, :page_size => 1500 - assigns(:page_size).should eq Author.story_max_page_size + get :scroll_panels, :id => @other_author.id, :page_size => 1500 + assigns(:page_size).should eq Author.scroll_panel_max_page_size end it 'ä¸æ£ãªå¤ãå ¥ãã¨@page_sizeã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :stories, :id => @other_author.id, :page_size => 0 - assigns(:page_size).should eq Author.default_story_page_size + get :scroll_panels, :id => @other_author.id, :page_size => 0 + assigns(:page_size).should eq Author.default_scroll_panel_page_size end end context 'ã¤ã¤ããªãçµããã¨ã' do it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end it 'ä½å®¶ã¢ãã«ã«åä½åå¾ãåãåããã¦ãã' do Author.should_receive(:show).exactly(1) - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id end it 'ã¹ãã¼ãªã¼ã¢ãã«ã«ä»ä½å®¶ã®ã¹ãã¼ãªã¼ä¸è¦§ãåãåããã¦ãã' do - Story.should_receive(:himlist).exactly(1) - get :stories, :id => @other_author.id + ScrollPanel.should_receive(:himlist).exactly(1) + get :scroll_panels, :id => @other_author.id end - it '@storiesã«ãªã¹ããåå¾ãã¦ãã' do - get :stories, :id => @other_author.id - assigns(:stories).should have_at_least(3).items + it '@scroll_panelsã«ãªã¹ããåå¾ãã¦ãã' do + get :scroll_panels, :id => @other_author.id + assigns(:scroll_panels).should have_at_least(3).items end context 'htmlå½¢å¼' do it '@paginateã«ãã¼ã¸å¶å¾¡ãåå¾ãã¦ãã' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true end - it 'storiesãã³ãã¬ã¼ããæç»ãã' do - get :stories, :id => @other_author.id - response.should render_template("stories") + it 'scroll_panelsãã³ãã¬ã¼ããæç»ãã' do + get :scroll_panels, :id => @other_author.id + response.should render_template("scroll_panels") end end context 'jsonå½¢å¼' do it 'jsonãã¼ã¿ãè¿ã' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end it 'ã¹ãã¼ãªã¼ã¢ãã«ã«jsonä¸è¦§åºåãªãã·ã§ã³ãåãåããã¦ãã' do - Story.should_receive(:list_json_opt).exactly(1) - get :stories, :id => @other_author.id, :format => :json + ScrollPanel.should_receive(:list_json_opt).exactly(1) + get :scroll_panels, :id => @other_author.id, :format => :json end it 'ãã¼ã¿ããªã¹ãæ§é ã«ãªã£ã¦ãã' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json json = JSON.parse response.body json.should have_at_least(3).items end it 'ãªã¹ãã®å é ãããã¯ã¹ãã¼ãªã¼ã£ã½ããã®ã§ãã£ã¦æ¬²ãã' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json json = JSON.parse response.body json.first.has_key?("panel_id").should be_true - json.first.has_key?("comic_id").should be_true + json.first.has_key?("scroll_id").should be_true json.first.has_key?("t").should be_true end end @@ -469,21 +469,21 @@ if MagicNumber['run_mode'] == 1 end context 'htmlå½¢å¼' do it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.status.should eq 302 end it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should redirect_to '/users/sign_in' end end context 'jsonå½¢å¼' do it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json response.status.should eq 401 end it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json response.message.should match(/Unauthorized/) end end @@ -494,7 +494,7 @@ if MagicNumber['run_mode'] == 1 sign_in @admin end it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end end @@ -503,7 +503,7 @@ if MagicNumber['run_mode'] == 1 @author.destroy end it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end end @@ -1780,24 +1780,24 @@ else @other_user = FactoryGirl.create( :user_yas) @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id - Comic.stub(:mylist).and_return([@comic, @comic, @comic]) + @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id + Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll]) sign_in @user end context 'ã¤ã¤ããªãçµããã¨ã' do it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end context 'htmlå½¢å¼' do - it 'comicãã³ãã¬ã¼ããæç»ãã' do - get :comics, :id => @other_author.id - response.should render_template("comic") + it 'scrollãã³ãã¬ã¼ããæç»ãã' do + get :scrolls, :id => @other_author.id + response.should render_template("scroll") end end context 'jsonå½¢å¼' do it 'jsonãã¼ã¿ãè¿ã' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end end @@ -1807,18 +1807,18 @@ else sign_out @user end it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end context 'htmlå½¢å¼' do - it 'comicsãã³ãã¬ã¼ããæç»ãã' do - get :comics, :id => @other_author.id - response.should render_template("comics") + it 'scrollsãã³ãã¬ã¼ããæç»ãã' do + get :scrolls, :id => @other_author.id + response.should render_template("scrolls") end end context 'jsonå½¢å¼' do it 'jsonãã¼ã¿ãè¿ã' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end end @@ -1830,26 +1830,26 @@ else @other_user = FactoryGirl.create( :user_yas) @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id + @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id @panel = FactoryGirl.create :panel, :author_id => @other_author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_author.id - Story.stub(:mylist).and_return([@story, @story, @story]) + @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_author.id + ScrollPanel.stub(:mylist).and_return([@scroll_panel, @scroll_panel, @scroll_panel]) sign_in @user end context 'ã¤ã¤ããªãçµããã¨ã' do it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end context 'htmlå½¢å¼' do - it 'storiesãã³ãã¬ã¼ããæç»ãã' do - get :stories, :id => @other_author.id - response.should render_template("stories") + it 'scroll_panelsãã³ãã¬ã¼ããæç»ãã' do + get :scroll_panels, :id => @other_author.id + response.should render_template("scroll_panels") end end context 'jsonå½¢å¼' do it 'jsonãã¼ã¿ãè¿ã' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end end @@ -1859,18 +1859,18 @@ else sign_out @user end it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end context 'htmlå½¢å¼' do - it 'storiesãã³ãã¬ã¼ããæç»ãã' do - get :stories, :id => @other_author.id - response.should render_template("stories") + it 'scroll_panelsãã³ãã¬ã¼ããæç»ãã' do + get :scroll_panels, :id => @other_author.id + response.should render_template("scroll_panels") end end context 'jsonå½¢å¼' do it 'jsonãã¼ã¿ãè¿ã' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end end diff --git a/spec/controllers/comics_controller_spec.rb b/spec/controllers/comics_controller_spec.rb deleted file mode 100644 index 449cbcbe..00000000 --- a/spec/controllers/comics_controller_spec.rb +++ /dev/null @@ -1,1301 +0,0 @@ -# -*- encoding: utf-8 -*- -require 'spec_helper' -#ã³ãã㯠-describe ComicsController do - before do - @admin =FactoryGirl.create :admin - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @user = FactoryGirl.create :user_yas - @author = FactoryGirl.create :author, :user_id => @user.id - end - -if MagicNumber['run_mode'] == 1 - describe 'ä¸è¦§è¡¨ç¤ºã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - Comic.stub(:list).and_return([@comic, @comic, @comic]) - sign_in @user - end - context 'äºåãã§ãã¯ãã' do - it 'ä¸ããããpageãã»ããããã¦ãã' do - get :index, :page => 5 - assigns(:page).should eq 5 - end - it 'çç¥ãããã¨@pageã«1å¤ãå ¥ã' do - get :index - assigns(:page).should eq 1 - end - it 'ä¸ããããpage_sizeãã»ããããã¦ãã' do - get :index, :page_size => 15 - assigns(:page_size).should eq 15 - end - it 'çç¥ãããã¨@page_sizeã«ããã©ã«ãå¤ãå ¥ã' do - get :index - assigns(:page_size).should eq Comic.default_page_size - end - it 'æ大ãè¶ ããã¨@page_sizeã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :index, :page_size => 1500 - assigns(:page_size).should eq Comic.max_page_size - end - it 'ä¸æ£ãªå¤ãå ¥ãã¨@page_sizeã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :index, :page_size => 0 - assigns(:page_size).should eq Comic.default_page_size - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - it 'ã³ããã¯ã¢ãã«ã«ä¸è¦§ãåãåããã¦ãã' do - Comic.should_receive(:list).exactly(1) - get :index - end - it '@comicsã«ãªã¹ããåå¾ãã¦ãã' do - get :index - assigns(:comics).should have_at_least(3).items - end - context 'htmlå½¢å¼' do - it '@paginateã«ãã¼ã¸å¶å¾¡ãåå¾ãã¦ãã' do - get :index - assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true - end - it 'indexãã³ãã¬ã¼ããæç»ãã' do - get :index - response.should render_template("index") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ã³ããã¯ã¢ãã«ã«jsonä¸è¦§åºåãªãã·ã§ã³ãåãåããã¦ãã' do - Comic.should_receive(:list_json_opt).exactly(1) - get :index, :format => :json - end - it 'ãã¼ã¿ããªã¹ãæ§é ã«ãªã£ã¦ãã' do - get :index, :format => :json - json = JSON.parse response.body - json.should have_at_least(3).items - end - it 'ãªã¹ãã®å é ãããã¯ã³ããã¯ã£ã½ããã®ã§ãã£ã¦æ¬²ãã' do - get :index, :format => :json - json = JSON.parse response.body - json.first.has_key?("title").should be_true - json.first.has_key?("visible").should be_true - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :index - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :index - response.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :index, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :index, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - end - end - end - - describe 'åä½è¡¨ç¤ºã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id, :title => 'normal' - Comic.stub(:show).and_return(@comic) - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @comic.id - response.should be_success - end - it 'ã³ããã¯ã¢ãã«ã«åä½åå¾ãåãåããã¦ãã' do - Comic.should_receive(:show).exactly(1) - get :show - end - it '@comicã«ã¢ã¬ãåå¾ãã¦ãã' do - get :show, :id => @comic.id - assigns(:comic).id.should eq(@comic.id) - end - context 'htmlå½¢å¼' do - it 'showãã³ãã¬ã¼ããæç»ãã' do - get :show, :id => @comic.id - response.should render_template("show") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :show, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ã³ããã¯ã¢ãã«ã«jsonåä½åºåãªãã·ã§ã³ãåãåããã¦ãã' do - Comic.should_receive(:show_json_opt).exactly(1) - get :show, :id => @comic.id, :format => :json - end - it 'ãã¼ã¿ãã¢ã¬ã«ãªã£ã¦ãã' do - get :show, :id => @comic.id, :format => :json - json = JSON.parse response.body - json["title"].should match(/normal/) - json["visible"].should_not be_nil - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :show, :id => @comic.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :show, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :show, :id => @comic.id, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :show, :id => @comic.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @comic.id - response.should be_success - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @comic.id - response.should be_success - end - end - end -=begin - context '対象ã³ããã¯ããªãã¨ã' do - context 'htmlå½¢å¼' do - it 'ä¾å¤404 not_foundãè¿ã' do - lambda{ - get :show, :id => 0 - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - context 'jsonå½¢å¼' do - it 'ä¾å¤404 not_foundãè¿ã' do - lambda{ - get :show, :id => 0, :format => :json - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - context 'éå ¬éã³ããã¯ãè¦ããã¨ããã¨ã' do - context 'htmlå½¢å¼' do - it 'ä¾å¤403 forbiddenãè¿ã' do - Comic.any_instance.stub(:visible?).with(any_args()).and_return(false) - hidden = FactoryGirl.create :hidden_comic, :author_id => @author.id - lambda{ - get :show, :id => hidden - }.should raise_error(ActiveRecord::Forbidden) - end - end - context 'jsonå½¢å¼' do - it 'ä¾å¤403 forbiddenãè¿ã' do - Comic.any_instance.stub(:visible?).with(any_args()).and_return(false) - hidden = FactoryGirl.create :hidden_comic, :author_id => @author.id - lambda{ - get :show, :id => hidden, :format => :json - }.should raise_error(ActiveRecord::Forbidden) - end - end - end -=end - end - describe 'ã³ããã¯æ°åå¾ã«æ¼ãã¦' do - before do - Comic.should_receive(:visible_count).and_return(3) -# sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :count, :format => :json - response.should be_success - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :count, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ãã¼ã¿ãHashæ§é ã«ãªã£ã¦ãã¦ã³ããã¯æ°ã1ã§ãã' do - get :count, :format => :json - json = JSON.parse response.body - json["count"].should == 3 - end - end - end - end - - describe 'æ°è¦ä½æãã©ã¼ã 表示ã«æ¼ãã¦' do - before do - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :new - response.should be_success - end - it '@comicã«æ°è¦ãã¼ã¿ãç¨æãã¦ãã' do - get :new - assigns(:comic).should be_a_new(Comic) - end - it 'ã³ããã¯ã¢ãã«ã«ããã©ã«ãå¤è£å ãä¾é ¼ãã¦ãã' do - Comic.any_instance.should_receive(:supply_default).exactly(1) - get :new - end - context 'htmlå½¢å¼' do - it 'newãã³ãã¬ã¼ããæç»ãã' do - get :new - response.should render_template("new") - end - end - context 'jså½¢å¼' do - it 'new.jsãã³ãã¬ã¼ããæç»ãã' do - get :new, :format => :js - response.should render_template("new") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ã³ããã¯ã¢ãã«ã«jsonåä½åºåãªãã·ã§ã³ãåãåããã¦ãã' do - Comic.should_receive(:show_json_opt).exactly(1) - get :new, :format => :json - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :new - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :new, :format => :js - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :new, :format => :js - response.message.should match(/Unauthorized/) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :new, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :new, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :new - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :new, @attr - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - get :new, @attr - response.body.should redirect_to new_author_path - end - end - end - end - - describe 'æ°è¦ä½æã«æ¼ãã¦' do - before do - sign_in @user - @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'normal') - end - context 'äºåãã§ãã¯ãã¦ãã' do - it 'ã³ããã¯ã¢ãã«ã«ããã©ã«ãå¤è£å ãä¾é ¼ãã¦ãã' do - Comic.any_instance.should_receive(:supply_default).exactly(1) - post :create, :comic => @attr - end - it 'ã³ããã¯ã¢ãã«ã«ã«ã©ã å¤å¾©å ãä¾é ¼ãã¦ãã' do - Comic.any_instance.should_receive(:attributes=).exactly(1) - post :create, :comic => @attr - end - it 'ã³ããã¯ã¢ãã«ã«ä¸æ¸ãè£å ãä¾é ¼ãã¦ãã' do - Comic.any_instance.should_receive(:overwrite).exactly(1) - post :create, :comic => @attr - end - it 'ã¢ãã«ã«ä¿åä¾é ¼ãã' do - Comic.any_instance.should_receive(:save).exactly(1) - post :create, :comic => @attr - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it "@comicã«ä½æãããã³ããã¯ãä¿æãã¦ãã¦ããããDBã«ãã" do - post :create, :comic => @attr - assigns(:comic).should be_a(Comic) - assigns(:comic).should be_persisted - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr - response.status.should eq 302 - end - it 'ä½æãããã³ããã¯ã®è¡¨ç¤ºãã¼ã¸ã¸é·ç§»ãã' do -# Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr - response.should redirect_to(Comic.last) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do -# Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr, :format => :json - response.should be_success - end - it 'ä½æãããã³ããã¯ãjsonãã¼ã¿ã§è¿ã' do - post :create, :comic => @attr, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ãã¼ã¿ãã¢ã¬ã«ãªã£ã¦ãã' do - post :create, :comic => @attr, :format => :json - json = JSON.parse response.body - json["title"].should match(/normal/) - json["visible"].should_not be_nil - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - post :create, :comic => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - post :create, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - post :create, :comic => @attr, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - post :create, :comic => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - post :create, :comic => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - post :create, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - post :create, :comic => @attr - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - post :create, :comic => @attr - response.body.should redirect_to new_author_path - end - end - end - context 'æ¤è¨¼ãä¿åã«å¤±æãã' do - before do - Comic.any_instance.stub(:save).and_return(false) - end - it "æªä¿åã®ã³ããã¯ãä¿æãã¦ãã" do - post :create, :comic => @attr - assigns(:comic).should be_a_new(Comic) - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - post :create, :comic => @attr - response.status.should eq 200 - end - it 'æ°è¦ãã¼ã¸ãæç»ãã' do - post :create, :comic => @attr - response.should render_template("new") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã422 unprocessable_entity ãè¿ã' do - post :create, :comic => @attr, :format => :json - response.status.should eq 422 - end - it 'å¿çã¡ãã»ã¼ã¸Unprocessable Entityãè¿ã' do - post :create, :comic => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - - describe 'ç·¨éãã©ã¼ã 表示ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - sign_in @user - Comic.stub(:edit).and_return(@comic) - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :edit, :id => @comic.id - response.should be_success - end - it 'ã³ããã¯ã¢ãã«ã«ç·¨éåå¾ãåãåããã¦ãã' do - Comic.should_receive(:edit).exactly(1) - get :edit, :id => @comic.id - end - it '@comicã«ãã¼ã¿ãç¨æãã¦ãã' do - get :edit, :id => @comic.id - assigns(:comic).should eq @comic - end - context 'htmlå½¢å¼' do - it 'editãã³ãã¬ã¼ããæç»ãã' do - get :edit, :id => @comic.id - response.should render_template("edit") - end - end - context 'jså½¢å¼' do - it 'edit.jsãã³ãã¬ã¼ããæç»ãã' do - get :edit, :id => @comic.id, :format => :js - response.should render_template("edit") - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :edit, :id => @comic.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :edit, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :edit, :id => @comic.id, :format => :js - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :edit, :id => @comic.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :edit, :id => @comic.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :edit, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :edit, :id => @comic.id - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - get :edit, :id => @comic.id - response.body.should redirect_to new_author_path - end - end - end - end - - describe 'æ´æ°ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author => @author - @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'updated title', :visible => 0) - sign_in @user - end - context 'äºåãã§ãã¯ãã¦ãã' do - it 'ã³ããã¯ã¢ãã«ã«ç·¨éåå¾ãåãåããã¦ãã' do - Comic.stub(:edit).with(any_args()).and_return @comic - Comic.should_receive(:edit).exactly(1) - put :update, :id => @comic.id, :comic => @attr - end - it 'ã³ããã¯ã¢ãã«ã«ã«ã©ã å¤å¾©å ãä¾é ¼ãã¦ãã' do - Comic.any_instance.should_receive(:attributes=).exactly(1) - put :update, :id => @comic.id, :comic => @attr - end - it 'ã³ããã¯ã¢ãã«ã«ä¸æ¸ãè£å ãä¾é ¼ãã¦ãã' do - Comic.any_instance.should_receive(:overwrite).exactly(1) - put :update, :id => @comic.id, :comic => @attr - end - it 'ã¢ãã«ã«æ´æ°ãä¾é ¼ãã' do - Comic.any_instance.stub(:save).with(any_args).and_return true - Comic.any_instance.should_receive(:save).exactly(1) - put :update, :id => @comic.id, :comic => @attr - end - it '@comicã«ã¢ã¬ãåå¾ãã¦ãã' do - put :update, :id => @comic.id, :comic => @attr - assigns(:comic).id.should eq(@comic.id) - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'æ´æ°ããã' do - put :update, :id => @comic.id, :comic => @attr - Comic.find(@comic.id).visible.should eq 0 - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it 'æ´æ°ãããã³ããã¯ã®è¡¨ç¤ºãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @comic.id, :comic => @attr - response.should redirect_to(@comic) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.should be_success - end - it 'ãã¼ã¸æ¬ä½ã¯ç¹ã«è¿ããªã' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.body.should match /./ - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @comic.id, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @comic.id, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @comic.id, :comic => @attr - response.body.should redirect_to new_author_path - end - end - end - context 'æ¤è¨¼ãä¿åã«å¤±æããã¨ã' do - before do - Comic.any_instance.stub(:save).and_return(false) - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 Okãè¿ã' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 200 - end - it 'ç·¨éãã¼ã¸ãæç»ãã' do - put :update, :id => @comic.id, :comic => @attr - response.should render_template("edit") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã422 unprocessable_entity ãè¿ã' do - Comic.any_instance.stub(:save).and_return(false) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.status.should eq 422 - end - it 'å¿çã¡ãã»ã¼ã¸Unprocessable Entityãè¿ã' do - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - - describe 'åé¤ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author => @author - sign_in @user - end - context 'äºåãã§ãã¯ãã¦ãã' do - before do - Comic.stub(:edit).with(any_args()).and_return @comic - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'ã³ããã¯ã¢ãã«ã«ç·¨éåå¾ãåãåããã¦ãã' do - Comic.should_receive(:edit).exactly(1) - delete :destroy, :id => @comic.id - end - it 'ã¢ãã«ã«åé¤ãä¾é ¼ãã' do - Comic.any_instance.should_receive(:destroy_with_story).exactly(1) - delete :destroy, :id => @comic.id - end - it '@comicã«ã¢ã¬ãåå¾ãã¦ãã' do - delete :destroy, :id => @comic.id - assigns(:comic).id.should eq(@comic.id) - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'åé¤ããã' do - lambda { - delete :destroy, :id => @comic.id - }.should change Comic, :count - end - context 'htmlå½¢å¼' do - before do - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'ãã¤ã³ããã¯ã®ä¸è¦§ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @comic.id - response.should redirect_to('/home/comics') - end - end - context 'jsonå½¢å¼' do - before do - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - delete :destroy, :id => @comic.id, :format => :json - response.should be_success - end - it 'ãã¼ã¸æ¬ä½ã¯ç¹ã«è¿ããªã' do - delete :destroy, :id => @comic.id, :format => :json - response.body.should match /./ - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - delete :destroy, :id => @comic.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @comic.id - response.body.should redirect_to new_author_path - end - end - end - context 'åé¤ã«å¤±æããã¨ã' do - before do - Comic.any_instance.stub(:destroy_with_story).and_return(false) - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'ãã®ã³ããã¯ã®è©³ç´°ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @comic.id - response.should redirect_to(comic_path(@comic)) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã422 unprocessable_entity ãè¿ã' do - delete :destroy, :id => @comic.id, :format => :json - response.status.should eq 422 - end - it 'å¿çã¡ãã»ã¼ã¸Unprocessable Entityãè¿ã' do - delete :destroy, :id => @comic.id, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - -else - describe 'ä¸è¦§è¡¨ç¤ºã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - Comic.stub(:list).and_return([@comic, @comic, @comic]) - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - context 'htmlå½¢å¼' do - it 'indexãã³ãã¬ã¼ããæç»ãã' do - get :index - response.should render_template("index") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - context 'htmlå½¢å¼' do - it 'indexãã³ãã¬ã¼ããæç»ãã' do - get :index - response.should render_template("index") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe 'åä½è¡¨ç¤ºã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id, :title => 'normal' - Comic.stub(:show).and_return(@comic) - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @comic.id - response.should be_success - end - context 'htmlå½¢å¼' do - it 'showãã³ãã¬ã¼ããæç»ãã' do - get :show, :id => @comic.id - response.should render_template("show") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :show, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @comic.id - response.should be_success - end - context 'htmlå½¢å¼' do - it 'showãã³ãã¬ã¼ããæç»ãã' do - get :show, :id => @comic.id - response.should render_template("show") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :show, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - describe 'ã³ããã¯æ°åå¾ã«æ¼ãã¦' do - before do - Comic.should_receive(:visible_count).and_return(3) - sign_out @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :count, :format => :json - response.should be_success - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :count, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe 'æ°è¦ä½æãã©ã¼ã 表示ã«æ¼ãã¦' do - before do - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :new - response.should be_success - end - context 'htmlå½¢å¼' do - it 'newãã³ãã¬ã¼ããæç»ãã' do - get :new - response.should render_template("new") - end - end - context 'jså½¢å¼' do - it 'new.jsãã³ãã¬ã¼ããæç»ãã' do - get :new, :format => :js - response.should render_template("new") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :new - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :new, :format => :js - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :new, :format => :js - response.message.should match(/Unauthorized/) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :new, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :new, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe 'æ°è¦ä½æã«æ¼ãã¦' do - before do - sign_in @user - @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'normal') - end - context 'ã¤ã¤ããªãçµããã¨ã' do - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr - response.status.should eq 302 - end - it 'ä½æãããã³ããã¯ã®è¡¨ç¤ºãã¼ã¸ã¸é·ç§»ãã' do -# Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr - response.should redirect_to(Comic.last) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do -# Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr, :format => :json - response.should be_success - end - it 'ä½æãããã³ããã¯ãjsonãã¼ã¿ã§è¿ã' do - post :create, :comic => @attr, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - post :create, :comic => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - post :create, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - post :create, :comic => @attr, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - post :create, :comic => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe 'ç·¨éãã©ã¼ã 表示ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - sign_in @user - Comic.stub(:edit).and_return(@comic) - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :edit, :id => @comic.id - response.should be_success - end - context 'htmlå½¢å¼' do - it 'editãã³ãã¬ã¼ããæç»ãã' do - get :edit, :id => @comic.id - response.should render_template("edit") - end - end - context 'jså½¢å¼' do - it 'edit.jsãã³ãã¬ã¼ããæç»ãã' do - get :edit, :id => @comic.id, :format => :js - response.should render_template("edit") - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :edit, :id => @comic.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :edit, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :edit, :id => @comic.id, :format => :js - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :edit, :id => @comic.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - end - - describe 'æ´æ°ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author => @author - @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'updated title', :visible => 0) - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it 'æ´æ°ãããã³ããã¯ã®è¡¨ç¤ºãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @comic.id, :comic => @attr - response.should redirect_to(@comic) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.should be_success - end - it 'ãã¼ã¸æ¬ä½ã¯ç¹ã«è¿ããªã' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.body.should match /./ - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - context 'htmlå½¢å¼' do - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @comic.id, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - end - - describe 'åé¤ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author => @author - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - context 'htmlå½¢å¼' do - before do - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'ãã¤ã³ããã¯ã®ä¸è¦§ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @comic.id - response.should redirect_to('/home/comic') - end - end - context 'jsonå½¢å¼' do - before do - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - delete :destroy, :id => @comic.id, :format => :json - response.should be_success - end - it 'ãã¼ã¸æ¬ä½ã¯ç¹ã«è¿ããªã' do - delete :destroy, :id => @comic.id, :format => :json - response.body.should match /./ - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - context 'htmlå½¢å¼' do - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - delete :destroy, :id => @comic.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - -end - -end diff --git a/spec/controllers/speech_balloon_templates_controller_spec.rb b/spec/controllers/speech_balloon_templates_controller_spec.rb index 08eb32f9..2fb447e0 100644 --- a/spec/controllers/speech_balloon_templates_controller_spec.rb +++ b/spec/controllers/speech_balloon_templates_controller_spec.rb @@ -17,11 +17,11 @@ if MagicNumber['run_mode'] == 1 describe 'ä¸è¦§è¡¨ç¤ºã«æ¼ãã¦' do before do sign_in @user - SpeechBalloonTemplate.stub(:list).and_return([@sbt, @sbt, @sbt]) + SpeechBalloonTemplate.stub(:enable_list).and_return([@sbt, @sbt, @sbt]) end context 'ã¤ã¤ããªãçµããã¨ã' do it 'ãããã·ãã³ãã¬ã¼ãã¢ãã«ã«ä¸è¦§ãåãåããã¦ãã' do - SpeechBalloonTemplate.should_receive(:list).exactly(1) + SpeechBalloonTemplate.should_receive(:enable_list).exactly(1) get :index end it '@speech_balloon_templatesã«ãªã¹ããåå¾ãã¦ãã' do diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb deleted file mode 100644 index 7e7a4d48..00000000 --- a/spec/controllers/stories_controller_spec.rb +++ /dev/null @@ -1,1456 +0,0 @@ -# -*- encoding: utf-8 -*- -require 'spec_helper' -#ã¹ãã¼ãªã¼ -describe StoriesController do - before do - @admin = FactoryGirl.create :admin - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @user = FactoryGirl.create :user_yas - @author = FactoryGirl.create :author, :user_id => @user.id - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - -if MagicNumber['run_mode'] == 1 - describe 'ä¸è¦§è¡¨ç¤ºã«æ¼ãã¦' do - before do - sign_in @user - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:list).and_return([@story, @story, @story]) - end - context 'ãã©ã¡ã¼ã¿pageã«ã¤ãã¦' do - it '@pageã«å¤ãå ¥ã' do - get :index, :page => 5 - assigns(:page).should eq 5 - end - it 'çç¥ãããã¨@pageã«1å¤ãå ¥ã' do - get :index - assigns(:page).should eq 1 - end - it 'ä¸ããããpage_sizeãã»ããããã¦ãã' do - get :index, :page_size => 15 - assigns(:page_size).should eq 15 - end - it 'çç¥ãããã¨@page_sizeã«ããã©ã«ãå¤ãå ¥ã' do - get :index - assigns(:page_size).should eq Story.default_page_size - end - it 'æ大ãè¶ ããã¨@page_sizeã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :index, :page_size => 1500 - assigns(:page_size).should eq Story.max_page_size - end - it 'ä¸æ£ãªå¤ãå ¥ãã¨@page_sizeã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :index, :page_size => 0 - assigns(:page_size).should eq Story.default_page_size - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - it 'ã¹ãã¼ãªã¼ã¢ãã«ã«ä¸è¦§ãåãåããã¦ãã' do - Story.should_receive(:list).exactly(1) - get :index - end - it '@storiesã«ãªã¹ããåå¾ãã¦ãã' do - get :index - assigns(:stories).should have_at_least(3).items - end - context 'htmlå½¢å¼' do - it '@paginateã«ãã¼ã¸å¶å¾¡ãåå¾ãã¦ãã' do - get :index - assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true - end - it 'indexãã³ãã¬ã¼ããæç»ãã' do - get :index - response.should render_template("index") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ã¹ãã¼ãªã¼ã¢ãã«ã«jsonä¸è¦§åºåãªãã·ã§ã³ãåãåããã¦ãã' do - Story.should_receive(:list_json_opt).exactly(1) - get :index, :format => :json - end - it 'ãã¼ã¿ããªã¹ãæ§é ã«ãªã£ã¦ãã' do - get :index, :format => :json - json = JSON.parse response.body - json.should have_at_least(3).items - end - it 'ãªã¹ãã®å é ãããã¯ã¹ãã¼ãªã¼ã£ã½ããã®ã§ãã£ã¦æ¬²ãã' do - get :index, :format => :json - json = JSON.parse response.body - json.first.has_key?("panel_id").should be_true - json.first.has_key?("comic_id").should be_true - json.first.has_key?("t").should be_true - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :index - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :index - response.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :index, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :index, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - end - end - - describe 'åä½è¡¨ç¤ºã«æ¼ãã¦' do - before do - sign_in @user - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) - Story.stub(:show).with(@story.id.to_s, [@user, nil]).and_return(@story) - Story.stub(:show).with(@story.id.to_s, [nil, @admin]).and_return(@story) - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ãªã¼ã¢ãã«ã«åä½åå¾ãåãåããã¦ãã' do - Story.should_receive(:show).with(@story.id.to_s, [@user, nil]).exactly(1) - get :show, :id => @story.id - end - it '@storyã«ã¢ã¬ãåå¾ãã¦ãã' do - get :show, :id => @story.id - assigns(:story).should eq @story - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @story.id - response.should be_success - end - it 'showãã³ãã¬ã¼ããæç»ãã' do - get :show, :id => @story.id - response.should render_template("show") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @story.id, :format => :json - response.should be_success - end - it 'jsonãã¼ã¿ãè¿ã' do - get :show, :id => @story.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ã¹ãã¼ãªã¼ã¢ãã«ã«ã¹ãã¼ãªã¼jsonåºåãåãåããã¦ãã' do - Story.any_instance.should_receive(:story_as_json).exactly(1) - get :show, :id => @story.id, :format => :json - end - it 'ãã¼ã¿ãã¢ã¬ã«ãªã£ã¦ãã' do - get :show, :id => @story.id, :format => :json - json = JSON.parse response.body - json.has_key?("panel_id").should be_true - json.has_key?("comic_id").should be_true - json.has_key?("author_id").should be_true - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :show, :id => @story.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :show, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :show, :id => @story.id, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :show, :id => @story.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @story.id - response.should be_success - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @story.id - response.should be_success - end - end - end - - describe 'é²è¦§ã«æ¼ãã¦' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) - Story.stub(:count).and_return(10) - Story.stub(:play_list).with(any_args).and_return([@story, @story, @story]) - sign_in @user - end - context 'ãã©ã¡ã¼ã¿ãã§ãã¯ãã' do - it 'ä¸ããããoffsetãã»ããããã¦ãã' do - get :comic, :id => @comic.id, :offset => 5 - assigns(:offset).should eq 5 - end - it 'çç¥ãããã¨@offsetã«0å¤ãå ¥ã' do - get :comic, :id => @comic.id - assigns(:offset).should eq 0 - end - it 'ä¸ããããcountãã»ããããã¦ãã' do - get :comic, :id => @comic.id, :count => 4 - assigns(:panel_count).should eq 4 - end - it 'çç¥ãããã¨@panel_countã«ããã©ã«ãå¤ãå ¥ã' do - get :comic, :id => @comic.id - assigns(:panel_count).should eq Story.default_panel_size - end - it 'æ大ãè¶ ããã¨@panel_countã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :comic, :id => @comic.id, :count => 1500 - assigns(:panel_count).should eq Story.max_panel_size - end - it 'ä¸æ£ãªå¤ãå ¥ãã¨@panel_countã«ããã©ã«ãæ大å¤ãå ¥ã' do - get :comic, :id => @comic.id, :count => -1 - assigns(:panel_count).should eq Story.default_panel_size - end - end - context 'äºåãã§ãã¯ãã' do - it 'ã³ããã¯ã¢ãã«ã«åä½åå¾ãåãåããã¦ãã' do - Comic.should_receive(:show).with(@comic.id.to_s, [@user, nil]).exactly(1) - get :comic, :id => @comic.id - end - it 'ã¹ãã¼ãªã¼ã¢ãã«ã«ãã¬ã¤ãªã¹ãåå¾ãåãåããã¦ãã' do - Story.should_receive(:play_list).with(@comic, @author, 0, 30).exactly(1) - get :comic, :id => @comic.id - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it '@storiesã«ãªã¹ããåå¾ãã¦ãã' do - get :comic, :id => @comic.id - assigns(:stories).should have_at_least(3).items - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comic, :id => @comic.id - response.should be_success - end - it 'comicãã³ãã¬ã¼ããæç»ãã' do - get :comic, :id => @comic.id - response.should render_template("comic") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comic, :id => @comic.id, :format => :json - response.should be_success - end - it 'jsonãã¼ã¿ãè¿ã' do - get :comic, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ã¹ãã¼ãªã¼ã¢ãã«ã«ã¹ãã¼ãªã¼ãªã¹ãã®jsonåºåãåãåããã¦ãã' do - Story.should_receive(:list_as_json_text).exactly(1) - get :comic, :id => @comic.id, :format => :json - end - it 'ãã¼ã¿ããªã¹ãæ§é ã«ãªã£ã¦ãã' do - get :comic, :id => @comic.id, :format => :json - json = JSON.parse response.body - json.should have_at_least(3).items - end - it 'ãªã¹ãã®å é ãããã¯ã¹ãã¼ãªã¼ã£ã½ããã®ã§ãã£ã¦æ¬²ãã' do - get :comic, :id => @comic.id, :format => :json - json = JSON.parse response.body - json.first.has_key?("panel_id").should be_true - json.first.has_key?("comic_id").should be_true - json.first.has_key?("author_id").should be_true - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :comic, :id => @comic.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :comic, :id => @comic.id - response.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :comic, :id => @comic.id, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :comic, :id => @comic.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comic, :id => @comic.id - response.should be_success - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comic, :id => @comic.id - response.should be_success - end - end - end - - describe 'æ°è¦ä½æãã©ã¼ã 表示ã«æ¼ãã¦' do - before do - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it '@storyã«æ°è¦ãã¼ã¿ãç¨æãã¦ãã' do - get :new - assigns(:story).should be_a_new(Story) - end - it 'ã¢ãã«ã«ããã©ã«ãå¤è£å ãä¾é ¼ãã¦ãã' do - Story.any_instance.should_receive(:supply_default).exactly(1) - get :new - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :new - response.should be_success - end - it 'newãã³ãã¬ã¼ããæç»ãã' do - get :new - response.should render_template("new") - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :new, :format => :js - response.should be_success - end - it 'new.jsãã³ãã¬ã¼ããæç»ãã' do - get :new, :format => :js - response.should render_template("new") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :new, :format => :json - response.should be_success - end - it 'jsonãã¼ã¿ãè¿ã' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ã¹ãã¼ãªã¼ã¢ãã«ã®ã¹ãã¼ãªã¼ã®jsonåºåãåãåããã¦ãã' do - Story.any_instance.should_receive(:story_as_json).exactly(1) - get :new, :format => :json - end - it 'ãã¼ã¿ãã¢ã¬ã«ãªã£ã¦ãã' do - get :new, :format => :json - json = JSON.parse response.body - json.has_key?("panel_id").should be_true - json.has_key?("comic_id").should be_true - json.has_key?("author_id").should be_true - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :new - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :new, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :new, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :new - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :new - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - get :new - response.body.should redirect_to new_author_path - end - end - end - end - - describe 'æ°è¦ä½æã«æ¼ãã¦' do - before do - @attr = FactoryGirl.attributes_for(:story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id) - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ããã©ã«ãå¤è£å ãä¾é ¼ãã' do - Story.any_instance.should_receive(:supply_default).exactly(1) - post :create, :story => @attr - end - it 'POSTãã¼ã¿ãããã«ã©ã å¤ã復å ãã¦ãã' do - Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - assigns(:story).comic_id.should eq @comic.id - assigns(:story).panel_id.should eq @panel.id - end - it 'ä¸æ¸ãè£å ãä¾é ¼ãã' do - Story.any_instance.should_receive(:overwrite).exactly(1) - post :create, :story => @attr - end - it 'ã³ããã¯ã¢ãã«ã«ç·¨éåå¾ãä¾é ¼ãã¦ãã' do - Comic.should_receive(:edit).with(@comic.id, @author).exactly(1) - post :create, :story => @attr - end - it 'ã³ãã¢ãã«ã«åä½åå¾ãä¾é ¼ãã¦ãã' do - Panel.should_receive(:show).with(@panel.id, @author).exactly(1) - post :create, :story => @attr - end - it 'ã¢ãã«ã«ä¿åä¾é ¼ãã' do - Story.any_instance.should_receive(:store).exactly(1) - post :create, :story => @attr - end - it "@storyã«ä½æãããã³ããä¿æãã¦ãã¦ããããDBã«ãã" do - post :create, :story => @attr - assigns(:story).should be_a(Story) - assigns(:story).should be_persisted - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - response.status.should eq 302 - end - it 'ã³ããã¯ã®ã¹ãã¼ãªã¼è¡¨ç¤ºã¸é·ç§»ãã' do -# Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - response.should redirect_to(:action => :comic, :id => @attr[:comic_id]) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do -# Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr, :format => :json - response.should be_success - end - it 'ä½æãããã³ããjsonãã¼ã¿ã§è¿ã' do - post :create, :story => @attr, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ã¹ãã¼ãªã¼ã¢ãã«ã®ã¹ãã¼ãªã¼ã®jsonåºåãåãåããã¦ãã' do - Story.any_instance.should_receive(:story_as_json).exactly(1) - post :create, :story => @attr, :format => :json - end - it 'ãã¼ã¿ãã¢ã¬ã«ãªã£ã¦ãã' do - post :create, :story => @attr, :format => :json - json = JSON.parse response.body - json["t"].should eq 0 - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - post :create, :story => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - post :create, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - post :create, :story => @attr, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - post :create, :story => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - post :create, :story => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - post :create, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - post :create, :story => @attr - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - post :create, :story => @attr - response.body.should redirect_to new_author_path - end - end - end - context 'æ¤è¨¼ãä¿åã«å¤±æãã' do - before do - Story.any_instance.stub(:store).and_return(false) - end - it "æªä¿åã®ã³ããä¿æãã¦ãã" do - post :create, :story => @attr - assigns(:story).should be_a_new(Story) - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - post :create, :story => @attr - response.status.should eq 200 - end - it 'æ°è¦ãã¼ã¸ãæç»ãã' do - post :create, :story => @attr - response.should render_template("new") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã422 unprocessable_entity ãè¿ã' do - post :create, :story => @attr, :format => :json - response.status.should eq 422 - end - it 'å¿çã¡ãã»ã¼ã¸Unprocessable Entityãè¿ã' do - post :create, :story => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - - describe 'ç·¨éãã©ã¼ã 表示ã«æ¼ãã¦' do - before do - @story = FactoryGirl.create :story, :author_id => @author.id - sign_in @user - Story.stub(:show).and_return(@story) - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ãªã¼ã¢ãã«ã«ç·¨éåå¾ãåãåããã¦ãã' do - Story.should_receive(:edit).exactly(1) - get :edit, :id => @story.id - end - it '@storyã«ãã¼ã¿ãç¨æãã¦ãã' do - get :edit, :id => @story.id - assigns(:story).should eq @story - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :edit, :id => @story.id - response.should be_success - end - it 'editãã³ãã¬ã¼ããæç»ãã' do - get :edit, :id => @story.id - response.should render_template("edit") - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :edit, :id => @story.id, :format => :js - response.should be_success - end - it 'edit.jsãã³ãã¬ã¼ããæç»ãã' do - get :edit, :id => @story.id, :format => :js - response.should render_template("edit") - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :edit, :id => @story.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :edit, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :edit, :id => @story.id, :format => :js - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :edit, :id => @story.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :edit, :id => @story.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :edit, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :edit, :id => @story.id - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - get :edit, :id => @story.id - response.body.should redirect_to new_author_path - end - end - end - end - - describe 'æ´æ°ã«æ¼ãã¦' do - before do - @story = FactoryGirl.create :story, :author_id => @user.author.id - @attr = FactoryGirl.attributes_for(:story, :author_id => @author.id) - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¢ãã«ã«ç·¨éåå¾ä¾é ¼ãã' do - Story.stub(:edit).with(any_args).and_return(@story) - Story.should_receive(:edit).exactly(1) - put :update, :id => @story.id, :story => @attr - end - it 'POSTãã¼ã¿ãããã«ã©ã å¤ã復å ãã¦ãã' do - Story.any_instance.stub(:store).and_return(true) - Story.any_instance.should_receive(:attributes=).exactly(1) - put :update, :id => @story.id, :story => @attr - end - it 'ä¸æ¸ãè£å ãä¾é ¼ãã' do - Story.any_instance.should_receive(:overwrite).exactly(1) - put :update, :id => @story.id, :story => @attr - end - it 'ã¢ãã«ã«ä¿åä¾é ¼ãã' do - Story.any_instance.should_receive(:store).exactly(1) - put :update, :id => @story.id, :story => @attr - end - it "@storyã«ä½æãããã¹ãã¼ãªã¼ãä¿æãã¦ãã¦ããããDBã«ãã" do - put :update, :id => @story.id, :story => @attr - assigns(:story).should be_a(Story) - assigns(:story).should be_persisted - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'ã¹ãã¼ãªã¼è¡¨ç¤ºã¸é·ç§»ãã' do -# Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr - response.should redirect_to(:action => :comic, :id => @attr[:comic_id]) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do -# Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr, :format => :json - response.should be_success - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @story.id, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @story.id, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @story.id, :story => @attr - response.body.should redirect_to new_author_path - end - end - end - context 'æ¤è¨¼ãä¿åã«å¤±æãã' do - before do - Story.any_instance.stub(:store).and_return(false) - end - it "æå®ã®ã³ããä¿æãã¦ãã" do - put :update, :id => @story.id, :story => @attr - assigns(:story).should eq @story - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 200 - end - it 'ç·¨éãã¼ã¸ãæç»ãã' do - put :update, :id => @story.id, :story => @attr - response.should render_template("edit") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã422 unprocessable_entity ãè¿ã' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.status.should eq 422 - end - it 'å¿çã¡ãã»ã¼ã¸Unprocessable Entityãè¿ã' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - - describe 'åé¤ã«æ¼ãã¦' do - before do - @story = FactoryGirl.create :story, :author_id => @author.id - sign_in @user - Story.stub(:edit).and_return(@story) - end - context 'äºåãã§ãã¯ãã¦ãã' do - before do - Story.stub(:edit).with(any_args()).and_return @story - Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true) - end - it 'ã¹ãã¼ãªã¼ã¢ãã«ã«ç·¨éåå¾ãåãåããã¦ãã' do - Story.should_receive(:edit).exactly(1) - delete :destroy, :id => @story.id - end - it 'ã¢ãã«ã«åé¤ãä¾é ¼ãã' do - Story.any_instance.should_receive(:destroy_and_shorten).exactly(1) - delete :destroy, :id => @story.id - end - it '@storyã«ã¢ã¬ãåå¾ãã¦ãã' do - delete :destroy, :id => @story.id - assigns(:story).id.should eq(@story.id) - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - before do - Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true) - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'é²è¦§ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @story.id - response.should redirect_to(:controller => 'stories', :action => :comic, :id => @story.comic_id) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - delete :destroy, :id => @story.id, :format => :json - response.should be_success - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - delete :destroy, :id => @story.id, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - delete :destroy, :id => @story.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ã¦ã¼ã¶æ¨©éã¯ãªãã管çè 権éãããã¨ã' do - before do - sign_out @user - sign_in @admin - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ã¦ã¼ã¶ã ãä½å®¶ç»é²ãã¦ããªãã¨ã' do - before do - @author.destroy - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'ä½å®¶ç»é²ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @story.id - response.body.should redirect_to new_author_path - end - end - end - context 'åé¤ã«å¤±æããã¨ã' do - before do - Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(false) - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'ãã®ã³ããã¯ã®è©³ç´°ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @story.id - response.should redirect_to(story_path(@story)) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã422 unprocessable_entity ãè¿ã' do - delete :destroy, :id => @story.id, :format => :json - response.status.should eq 422 - end - it 'å¿çã¡ãã»ã¼ã¸Unprocessable Entityãè¿ã' do - delete :destroy, :id => @story.id, :format => :json - response.message.should match(/Unprocessable/) - end - end - end -=begin - context '対象ã¹ãã¼ãªã¼ããªãã¨ã' do - end - context 'ä»äººã®ã¹ãã¼ãªã¼ã ã£ãã¨ã' do - end -=end - end - -else - describe 'ä¸è¦§è¡¨ç¤ºã«æ¼ãã¦' do - before do - sign_in @user - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:list).and_return([@story, @story, @story]) - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - context 'htmlå½¢å¼' do - it 'indexãã³ãã¬ã¼ããæç»ãã' do - get :index - response.should render_template("index") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :index - response.should be_success - end - context 'htmlå½¢å¼' do - it 'indexãã³ãã¬ã¼ããæç»ãã' do - get :index - response.should render_template("index") - end - end - context 'jsonå½¢å¼' do - it 'jsonãã¼ã¿ãè¿ã' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe 'åä½è¡¨ç¤ºã«æ¼ãã¦' do - before do - sign_in @user - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [nil, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) - Story.stub(:show).with(@story.id.to_s, [nil, nil]).and_return(@story) - Story.stub(:show).with(@story.id.to_s, [@user, nil]).and_return(@story) - Story.stub(:show).with(@story.id.to_s, [nil, @admin]).and_return(@story) - end - context 'ã¤ã¤ããªãçµããã¨ã' do - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @story.id - response.should be_success - end - it 'showãã³ãã¬ã¼ããæç»ãã' do - get :show, :id => @story.id - response.should render_template("show") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @story.id, :format => :json - response.should be_success - end - it 'jsonãã¼ã¿ãè¿ã' do - get :show, :id => @story.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @story.id - response.should be_success - end - it 'showãã³ãã¬ã¼ããæç»ãã' do - get :show, :id => @story.id - response.should render_template("show") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :show, :id => @story.id, :format => :json - response.should be_success - end - it 'jsonãã¼ã¿ãè¿ã' do - get :show, :id => @story.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe 'é²è¦§ã«æ¼ãã¦' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [nil, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) - Story.stub(:count).and_return(10) - Story.stub(:play_list).with(any_args).and_return([@story, @story, @story]) - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comic, :id => @comic.id - response.should be_success - end - it 'comicãã³ãã¬ã¼ããæç»ãã' do - get :comic, :id => @comic.id - response.should render_template("comic") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comic, :id => @comic.id, :format => :json - response.should be_success - end - it 'jsonãã¼ã¿ãè¿ã' do - get :comic, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comic, :id => @comic.id - response.should be_success - end - it 'comicãã³ãã¬ã¼ããæç»ãã' do - get :comic, :id => @comic.id - response.should render_template("comic") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :comic, :id => @comic.id, :format => :json - response.should be_success - end - it 'jsonãã¼ã¿ãè¿ã' do - get :comic, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe 'æ°è¦ä½æãã©ã¼ã 表示ã«æ¼ãã¦' do - before do - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :new - response.should be_success - end - it 'newãã³ãã¬ã¼ããæç»ãã' do - get :new - response.should render_template("new") - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :new, :format => :js - response.should be_success - end - it 'new.jsãã³ãã¬ã¼ããæç»ãã' do - get :new, :format => :js - response.should render_template("new") - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :new, :format => :json - response.should be_success - end - it 'jsonãã¼ã¿ãè¿ã' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :new - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :new, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :new, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe 'æ°è¦ä½æã«æ¼ãã¦' do - before do - @attr = FactoryGirl.attributes_for(:story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id) - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - response.status.should eq 302 - end - it 'ã³ããã¯ã®ã¹ãã¼ãªã¼è¡¨ç¤ºã¸é·ç§»ãã' do -# Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - response.should redirect_to(:action => :comic, :id => @attr[:comic_id]) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do -# Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr, :format => :json - response.should be_success - end - it 'ä½æãããã³ããjsonãã¼ã¿ã§è¿ã' do - post :create, :story => @attr, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - post :create, :story => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - post :create, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - post :create, :story => @attr, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - post :create, :story => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe 'ç·¨éãã©ã¼ã 表示ã«æ¼ãã¦' do - before do - @story = FactoryGirl.create :story, :author_id => @author.id - sign_in @user - Story.stub(:show).and_return(@story) - end - context 'ã¤ã¤ããªãçµããã¨ã' do - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :edit, :id => @story.id - response.should be_success - end - it 'editãã³ãã¬ã¼ããæç»ãã' do - get :edit, :id => @story.id - response.should render_template("edit") - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - get :edit, :id => @story.id, :format => :js - response.should be_success - end - it 'edit.jsãã³ãã¬ã¼ããæç»ãã' do - get :edit, :id => @story.id, :format => :js - response.should render_template("edit") - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - get :edit, :id => @story.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - get :edit, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jså½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - get :edit, :id => @story.id, :format => :js - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - get :edit, :id => @story.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - end - - describe 'æ´æ°ã«æ¼ãã¦' do - before do - @story = FactoryGirl.create :story, :author_id => @user.author.id - @attr = FactoryGirl.attributes_for(:story, :author_id => @author.id) - sign_in @user - end - context 'ã¤ã¤ããªãçµããã¨ã' do - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'ã¹ãã¼ãªã¼è¡¨ç¤ºã¸é·ç§»ãã' do -# Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr - response.should redirect_to(:action => :comic, :id => @attr[:comic_id]) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do -# Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr, :format => :json - response.should be_success - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - put :update, :id => @story.id, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe 'åé¤ã«æ¼ãã¦' do - before do - @story = FactoryGirl.create :story, :author_id => @author.id - sign_in @user - Story.stub(:edit).and_return(@story) - end - context 'ã¤ã¤ããªãçµããã¨ã' do - before do - Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true) - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'é²è¦§ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @story.id - response.should redirect_to(:controller => 'stories', :action => :comic, :id => @story.comic_id) - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã200 OKãè¿ã' do - delete :destroy, :id => @story.id, :format => :json - response.should be_success - end - end - end - context 'ã¦ã¼ã¶æ¨©éããªãã¨ã' do - before do - sign_out @user - end - context 'htmlå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã302 Foundãè¿ã' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'ãµã¤ã³ã¤ã³ãã¼ã¸ã¸é·ç§»ãã' do - delete :destroy, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'jsonå½¢å¼' do - it 'ã¹ãã¼ã¿ã¹ã³ã¼ã401 Unauthorizedãè¿ã' do - delete :destroy, :id => @story.id, :format => :json - response.status.should eq 401 - end - it 'å¿çã¡ãã»ã¼ã¸ã«Unauthorizedãè¿ã' do - delete :destroy, :id => @story.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - -end -end diff --git a/spec/factories.rb b/spec/factories.rb index d0e9aa67..0f29ff86 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -69,15 +69,9 @@ FactoryGirl.define do writing_format.settings '{}' end - factory :comic, :class => Comic do |comic| - comic.title "comic" - comic.description 'comic description' - comic.visible 1 - end - factory :scroll, :class => Scroll do |scroll| - scroll.title "comic" - scroll.description 'comic description' + scroll.title "scroll" + scroll.description 'scroll description' scroll.visible 1 end @@ -216,16 +210,6 @@ FactoryGirl.define do panel.author_id 1 end - factory :story, :class => Story do |story| - story.comic_id 1 - story.panel_id 1 - story.author_id 1 - story.t 0 - story.x nil - story.y nil - story.z nil - end - factory :provider, :class => Provider do |provider| provider.name 'admin@penguinkingdom.com' provider.caption 'ãã³ã®ã³çå½' diff --git a/spec/helpers/comics_helper_spec.rb b/spec/helpers/comics_helper_spec.rb deleted file mode 100644 index 3ffabda5..00000000 --- a/spec/helpers/comics_helper_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# -*- encoding: utf-8 -*- -#ã -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the ComicsHelper. For example: -# -# describe ComicsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe ComicsHelper do -end diff --git a/spec/models/comic_spec.rb b/spec/models/comic_spec.rb deleted file mode 100644 index 63fe8a1c..00000000 --- a/spec/models/comic_spec.rb +++ /dev/null @@ -1,840 +0,0 @@ -# -*- encoding: utf-8 -*- -require 'spec_helper' -#ã³ãã㯠- -describe Comic do - before do - @admin = FactoryGirl.create :admin - @demand_user = FactoryGirl.create :demand_user - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @user = FactoryGirl.create( :user_yas) - @author = FactoryGirl.create :author, :user_id => @user.id - @artist = FactoryGirl.create :artist_yas, :author_id => @author.id - @other_user = FactoryGirl.create( :user_yas) - @other_author = FactoryGirl.create :author, :user_id => @other_user.id - @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - end - - describe 'æ¤è¨¼ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - - context 'ãªã¼ã½ããã¯ã¹ãªãã¼ã¿ã®ã¨ã' do - it 'ä¸éãã¼ã¿ãéã' do - @comic.title = 'a' - @comic.visible = 0 - @comic.should be_valid - end - it 'ä¸éãã¼ã¿ãéã' do - @comic.title = 'a'*100 - @comic.visible = 1 - @comic.should be_valid - end - end - - context 'titleãæ¤è¨¼ããã¨ã' do - it 'nullãªã失æãã' do - @comic.title = nil - @comic.should_not be_valid - end - it '100æå以ä¸ãªã失æãã' do - @comic.title = 'a'*101 - @comic.should_not be_valid - end - end - context 'visibleãæ¤è¨¼ããã¨ã' do - it 'nullãªã失æãã' do - @comic.visible = nil - @comic.should_not be_valid - end - it 'è² ãªã失æãã' do - @comic.visible = -1 - @comic.should_not be_valid - end - it '2以ä¸ãªã失æãã' do - @comic.visible = 2 - @comic.should_not be_valid - end - end - end - - describe 'æåã³ã¼ãæ¤è¨¼ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - - context 'titleãæ¤è¨¼ããã¨ã' do - it 'Shift JISãªã失æãã' do - @comic.title = "\x83G\x83r\x83]\x83D" - lambda{ - @comic.valid_encode - }.should raise_error(Pettanr::BadRequest) - end - end - - context 'descriptionãæ¤è¨¼ããã¨ã' do - it 'Shift JISãªã失æãã' do - @comic.description = "\x83G\x83r\x83]\x83D" - lambda{ - @comic.valid_encode - }.should raise_error(Pettanr::BadRequest) - end - end - end - - describe 'ããã©ã«ãå¤è£å ã«æ¼ãã¦' do - it 'visibleã0ã«ãªã£ã¦ãã' do - @comic = FactoryGirl.build :comic, :visible => nil - @comic.supply_default - @comic.visible.should eq 0 - end - end - - describe 'ä¸æ¸ãè£å ã«æ¼ãã¦' do - it 'ä½å®¶idãè¨å®ããã¦ãã' do - @comic = FactoryGirl.build :comic, :author_id => nil - @comic.overwrite @author - @comic.author_id.should eq @author.id - end - end - - describe 'ãã¼ã«ãªã¹ãããã®ä½å®¶åå¾ã«æ¼ãã¦' do - context 'ãã¼ã«ãã¦ã¼ã¶ã®ã¨ã' do - it 'ã¦ã¼ã¶ããä½å®¶ãåå¾ãã¦ããããè¿ã' do - r = Comic.get_author_from_roles([@user]) - r.should eq @author - end - end - context 'ãã¼ã«ãä½å®¶ã®ã¨ã' do - it 'ä½å®¶ãè¿ã' do - r = Comic.get_author_from_roles([@author]) - r.should eq @author - end - end - context 'ãã¼ã«ã絵師ã®ã¨ã' do - it '絵師ããä½å®¶ãåå¾ã§ããã°ãããããè¿ã' do - r = Comic.get_author_from_roles([@artist]) - r.should eq @author - end - it '絵師ããä½å®¶ãåå¾ã§ããªãã¨ãnilãè¿ã' do - @artist.author_id = nil - @artist.save! - r = Comic.get_author_from_roles([@artist]) - r.should be_nil - end - end - context 'ãã¼ã«ã管çè ã®ã¨ã' do - it 'nilãè¿ã' do - r = Comic.get_author_from_roles([@admin]) - r.should be_nil - end - end - end - - describe 'ãã¼ã«ãªã¹ãããã®çµµå¸«åå¾ã«æ¼ãã¦' do - context 'ãã¼ã«ãã¦ã¼ã¶ã®ã¨ã' do - it 'ã¦ã¼ã¶ããä½å®¶ãåå¾ãã¦ããããã絵師ãåå¾ã§ããã°ããããè¿ã' do - r = Comic.get_artist_from_roles([@user]) - r.should eq @artist - end - it 'ä½å®¶ãã絵師ãåå¾ã§ããªãã¨ãnilãè¿ã' do - @artist.author_id = nil - @artist.save! - r = Comic.get_artist_from_roles([@user]) - r.should be_nil - end - end - context 'ãã¼ã«ãä½å®¶ã®ã¨ã' do - it 'ãããã絵師ãåå¾ã§ããã°ããããè¿ã' do - r = Comic.get_artist_from_roles([@author]) - r.should eq @artist - end - it 'ä½å®¶ãã絵師ãåå¾ã§ããªãã¨ãnilãè¿ã' do - @artist.author_id = nil - @artist.save! - r = Comic.get_artist_from_roles([@author]) - r.should be_nil - end - end - context 'ãã¼ã«ã絵師ã®ã¨ã' do - it 'ãããè¿ã' do - r = Comic.get_artist_from_roles([@artist]) - r.should eq @artist - end - end - context 'ãã¼ã«ã管çè ã®ã¨ã' do - it 'nilãè¿ã' do - r = Comic.get_artist_from_roles([@admin]) - r.should be_nil - end - end - end - - describe 'ææå¤å®ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - context 'äºåãã§ãã¯ãã' do - it 'èªèº«ã«ãã¼ã«ãªã¹ãããã®ä½å®¶åå¾ãä¾é ¼ãã¦ãã' do - Comic.should_receive(:get_author_from_roles).with(any_args).exactly(1) - r = @comic.own?([@author]) - end - end - context 'ãã¼ã«å ä½å®¶ãåå¾ã§ããã¨ã' do - before do - end - it 'ãã¼ã«å ä½å®¶ã®idãèªèº«ã®ä½å®¶idã¨ä¸è´ãããªã許å¯ãã' do - Comic.stub(:get_author_from_roles).with(any_args).and_return(@author) - r = @comic.own?([@author]) - r.should be_true - end - it 'ãã¼ã«å ä½å®¶ã®idãèªèº«ã®ä½å®¶idã¨ä¸è´ããªããªãno' do - Comic.stub(:get_author_from_roles).with(any_args).and_return(@other_author) - @comic.own?(@other_author).should be_false - end - end - context 'ãã¼ã«å ä½å®¶ãåå¾ã§ããªãã¨ã' do - before do - Comic.stub(:get_author_from_roles).with(any_args).and_return(nil) - end - it 'Falseãè¿ã' do - r = @comic.own?([@author]) - r.should be_false - end - end - end - - describe 'èªè ç¨ãã¼ã«ãã§ãã¯ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - context 'ãã¼ã«ãªã¹ãã«ä½å®¶ãå«ã¾ããã¨ã' do - it 'ãã¼ã«ãªã¹ãããªã¹ãã§ã¯ãªãã¨ãããªã¹ãã«ãã trueãè¿ã' do - r = @comic.reader_role_check(@author) - r.should be_true - end - it 'trueãè¿ã' do - r = @comic.reader_role_check([@author]) - r.should be_true - end - end - context 'ãã¼ã«ãªã¹ãã«çµµå¸«ãå«ã¾ããã¨ã' do - it 'trueãè¿ã' do - r = @comic.reader_role_check([@artist]) - r.should be_true - end - end - context 'ãã¼ã«ãªã¹ãã«ã¦ã¼ã¶ãå«ã¾ããã¨ã' do - it 'trueãè¿ã' do - r = @comic.reader_role_check([@user]) - r.should be_true - end - end - context 'ãã¼ã«ãªã¹ãã«ç®¡çè ãå«ã¾ããã¨ã' do - it 'trueãè¿ã' do - r = @comic.reader_role_check([@admin]) - r.should be_true - end - end - context 'ãã¼ã«ãªã¹ãã«ã¦ã¼ã¶ã管çè ãä½å®¶ã絵師ãå«ã¾ããªãã¨ã' do - it 'falseãè¿ã' do - r = @comic.reader_role_check([nil]) - r.should be_false - end - end - end - - describe 'ç´ æèªè ç¨ãã¼ã«ãã§ãã¯ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - context 'ãã¼ã«ãªã¹ãã«ä½å®¶ãå«ã¾ããã¨ã' do - it 'ãã¼ã«ãªã¹ãããªã¹ãã§ã¯ãªãã¨ãããªã¹ãã«ãã trueãè¿ã' do - r = @comic.resource_reader_role_check(@author) - r.should be_true - end - it 'trueãè¿ã' do - r = @comic.resource_reader_role_check([@author]) - r.should be_true - end - end - context 'ãã¼ã«ãªã¹ãã«çµµå¸«ãå«ã¾ããã¨ã' do - it 'trueãè¿ã' do - r = @comic.resource_reader_role_check([@artist]) - r.should be_true - end - end - context 'ãã¼ã«ãªã¹ãã«ã¦ã¼ã¶ãå«ã¾ããã¨ã' do - it 'trueãè¿ã' do - r = @comic.resource_reader_role_check([@user]) - r.should be_true - end - end - context 'ãã¼ã«ãªã¹ãã«ç®¡çè ãå«ã¾ããã¨ã' do - it 'trueãè¿ã' do - r = @comic.resource_reader_role_check([@admin]) - r.should be_true - end - end - context 'ãã¼ã«ãªã¹ãã«åæãå«ã¾ããã¨ã' do - it 'trueãè¿ã' do - r = @comic.resource_reader_role_check([@demand_user]) - r.should be_true - end - end - context 'ãã¼ã«ãªã¹ãã«ã¦ã¼ã¶ã管çè ãä½å®¶ã絵師ãåæãå«ã¾ããªãã¨ã' do - it 'falseãè¿ã' do - r = @comic.resource_reader_role_check([nil]) - r.should be_false - end - end - end - - describe 'é²è¦§è¨±å¯ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - context 'ãªã¼ãã³ã¢ã¼ãã®ã¨ã' do - before do - MagicNumber['run_mode'] = 0 - end - it 'èªèº«ã«ã²ã¹ãç¨ãã¼ã«ãã§ãã¯ãåãåãããã¦ãã' do - Comic.any_instance.stub(:guest_role_check).and_return(true) - Comic.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1) - r = @comic.visible?([@author]) - end - it 'ã²ã¹ãç¨ãã¼ã«ãã§ãã¯ã失æããã¨ããfalseãè¿ã' do - Comic.any_instance.stub(:guest_role_check).and_return(false) - r = @comic.visible?([@author]) - r.should be_false - end - end - context 'ã¯ãã¼ãºãã¢ã¼ãã®ã¨ã' do - before do - MagicNumber['run_mode'] = 1 - end - it 'èªèº«ã«èªè ç¨ãã¼ã«ãã§ãã¯ãåãåãããã¦ãã' do - Comic.any_instance.stub(:reader_role_check).and_return(true) - Comic.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1) - r = @comic.visible?([@author]) - end - it 'èªè ç¨ãã¼ã«ãã§ãã¯ã失æããã¨ããfalseãè¿ã' do - Comic.any_instance.stub(:reader_role_check).and_return(false) - r = @comic.visible?([@author]) - r.should be_false - end - end - context 'äºåãã§ãã¯ãã' do - before do - MagicNumber['run_mode'] = 1 - Comic.any_instance.stub(:reader_role_check).and_return(true) - Comic.any_instance.stub(:own?).and_return(true) - end - it 'èªèº«ã«ææå¤å®ãåãåãããã¦ãã' do - Comic.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = @comic.visible?([@author]) - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - before do - MagicNumber['run_mode'] = 1 - Comic.any_instance.stub(:reader_role_check).and_return(true) - end - it 'èªåã®ã³ããã¯ãªã許å¯ãã' do - Comic.any_instance.stub(:own?).and_return(true) - Comic.any_instance.stub(:visible).and_return(0) - r = @comic.visible?([@author]) - r.should be_true - end - it 'ä»äººã®éå ¬éã³ããã¯ãªã許å¯ããªã' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(0) - r = @comic.visible?([@author]) - r.should be_false - end - it 'ä»äººã®ã³ããã¯ã§ãå ¬éãªã許å¯ãã' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(1) - r = @comic.visible?([@author]) - r.should be_true - end - end - end - - describe 'ä¸è¦§åå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - end - context 'pageè£æ£ã«ã¤ãã¦' do - it 'æååããæ°å¤ã«å¤æããã' do - Comic.page('8').should eq 8 - end - it 'nilã®å ´åã¯1ã«ãªã' do - Comic.page().should eq 1 - end - it '0以ä¸ã®å ´åã¯1ã«ãªã' do - Comic.page('0').should eq 1 - end - end - context 'page_sizeè£æ£ã«ã¤ãã¦' do - it 'æååããæ°å¤ã«å¤æããã' do - Comic.page_size('7').should eq 7 - end - it 'nilã®å ´åã¯Comic.default_page_sizeã«ãªã' do - Comic.page_size().should eq Comic.default_page_size - end - it '0以ä¸ã®å ´åã¯Comic.default_page_sizeã«ãªã' do - Comic.page_size('0').should eq Comic.default_page_size - end - it 'Comic.max_page_sizeãè¶ ããå ´åã¯Comic.max_page_sizeã«ãªã' do - Comic.page_size('1000').should eq Comic.max_page_size - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ä¸è¦§åå¾ãªãã·ã§ã³ãå©ç¨ãã¦ãã' do - Comic.stub(:list_opt).with(any_args).and_return({}) - Comic.should_receive(:list_opt).with(any_args).exactly(1) - r = Comic.list - end - end - it 'ãªã¹ããè¿ã' do - c = Comic.list - c.should eq [@comic] - end - it 'éå ¬éã³ããã¯ã¯(èªåã®ã³ããã¯ã§ãã£ã¦ã)å«ãã§ããªã' do - FactoryGirl.create :comic, :author_id => @author.id, :visible => 0 - c = Comic.list - c.should eq [@comic] - end - it 'æç³»åã§ä¸¦ãã§ãã' do - #å ¬éã³ããã¯ã¯(ä»äººã®ã³ããã¯ã§ãã£ã¦ã)å«ãã§ãã - v = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 100 - c = Comic.list - c.should eq [v, @comic] - end - context 'DBã«5件ãã£ã¦1ãã¼ã¸ã®ä»¶æ°ã2件ã«å¤ããã¨ãã¦' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 100 - @comic3 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 200 - @comic4 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 300 - @comic5 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 400 - Comic.stub(:default_page_size).and_return(2) - end - it 'é常ã¯2件ãè¿ã' do - c = Comic.list - c.should have(2).items - end - it 'page=1ãªãæ«å°¾2件ãè¿ã' do - #æç³»åã§ä¸¦ãã§ãã - c = Comic.list(1) - c.should eq [@comic5, @comic4] - end - it 'page=2ãªãä¸é2件ãè¿ã' do - c = Comic.list(2) - c.should eq [@comic3, @comic2] - end - it 'page=3ãªãå é 1件ãè¿ã' do - c = Comic.list(3) - c.should eq [@comic] - end - end - end - - describe 'èªåã®ã³ããã¯ä¸è¦§åå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ä¸è¦§åå¾ãªãã·ã§ã³ãå©ç¨ãã¦ãã' do - Comic.stub(:list_opt).with(any_args).and_return({}) - Comic.should_receive(:list_opt).with(any_args).exactly(1) - r = Comic.mylist @author - end - end - it 'ãªã¹ããè¿ã' do - c = Comic.mylist @author - c.should eq [@comic] - end - it 'æç³»åã§ä¸¦ãã§ãã' do - nc = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 100 - cl = Comic.mylist @author - cl.should eq [nc, @comic] - end - it 'ä»äººã®ã³ããã¯ã¯å ¬éã§ãå«ã¾ãªã' do - nc = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - cl = Comic.mylist @author - cl.should eq [@comic] - end - it 'èªåã®ã³ããã¯ã¯éå ¬éã§ãå«ãã§ãã' do - nc = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0, :updated_at => Time.now + 100 - cl = Comic.mylist @author - cl.should eq [nc, @comic] - end - context 'DBã«5件ãã£ã¦1ãã¼ã¸ã®ä»¶æ°ã2件ã«å¤ããã¨ãã¦' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 100 - @comic3 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 200 - @comic4 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 300 - @comic5 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 400 - end - it 'é常ã¯2件ãè¿ã' do - c = Comic.mylist @author, 1, 2 - c.should have(2).items - end - it 'page=1ãªãæ«å°¾2件ãè¿ã' do - #æç³»åã§ä¸¦ãã§ãã - c = Comic.mylist(@author, 1, 2) - c.should eq [@comic5, @comic4] - end - it 'page=2ãªãä¸é2件ãè¿ã' do - c = Comic.mylist(@author, 2, 2) - c.should eq [@comic3, @comic2] - end - it 'page=3ãªãå é 1件ãè¿ã' do - c = Comic.mylist(@author, 3, 2) - c.should eq [@comic] - end - end - end - - describe 'ä»ä½å®¶ã®ã³ããã¯ä¸è¦§åå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ä¸è¦§åå¾ãªãã·ã§ã³ãå©ç¨ãã¦ãã' do - Comic.stub(:list_opt).with(any_args).and_return({}) - Comic.should_receive(:list_opt).with(any_args).exactly(1) - r = Comic.himlist @other_author - end - end - it 'æå®ããä½å®¶ã®ãªã¹ããè¿ã' do - r = Comic.himlist @other_author - r.should eq [@other_comic] - end - it 'æç³»åã§ä¸¦ãã§ãã' do - nc = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 100 - r = Comic.himlist @other_author - r.should eq [nc, @other_comic] - end - it 'å ¬éã³ããã¯ã«éã ' do - hidden = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 0 - r = Comic.himlist @other_author - r.should eq [@other_comic] - end - context 'DBã«5件ãã£ã¦1ãã¼ã¸ã®ä»¶æ°ã2件ã«å¤ããã¨ãã¦' do - before do - @other_comic2 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 100 - @other_comic3 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 200 - @other_comic4 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 300 - @other_comic5 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 400 - end - it 'é常ã¯2件ãè¿ã' do - c = Comic.himlist @other_author, 1, 2 - c.should have(2).items - end - it 'page=1ãªãæ«å°¾2件ãè¿ã' do - #æç³»åã§ä¸¦ãã§ãã - c = Comic.himlist(@other_author, 1, 2) - c.should eq [@other_comic5, @other_comic4] - end - it 'page=2ãªãä¸é2件ãè¿ã' do - c = Comic.himlist(@other_author, 2, 2) - c.should eq [@other_comic3, @other_comic2] - end - it 'page=3ãªãå é 1件ãè¿ã' do - c = Comic.himlist(@other_author, 3, 2) - c.should eq [@other_comic] - end - end - end - - describe 'ã³ããã¯ä¸è¦§ãã¼ã¸å¶å¾¡ã«æ¼ãã¦' do - before do - Comic.stub(:count).with(any_args).and_return(100) - end - it 'ãã¼ã¸å¶å¾¡ãè¿ã' do - r = Comic.list_paginate - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it 'ã³ããã¯ä¸è¦§ã®åå¾æ¡ä»¶ãå©ç¨ãã¦ãã' do - Comic.stub(:list_where).with(any_args).and_return('') - Comic.should_receive(:list_where).with(any_args).exactly(1) - r = Comic.list_paginate - end - it 'ãã¼ã¸ä»¶æ°10ã®ã¨ãã3ãã¼ã¸ç®ã®ãªãã»ããã¯20ããå§ã¾ã' do - r = Comic.list_paginate 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe 'èªåã®ã³ããã¯ä¸è¦§ãã¼ã¸å¶å¾¡ã«æ¼ãã¦' do - before do - Comic.stub(:count).with(any_args).and_return(100) - end - it 'ãã¼ã¸å¶å¾¡ãè¿ã' do - r = Comic.mylist_paginate @author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it 'èªåã®ã³ããã¯ä¸è¦§ã®åå¾æ¡ä»¶ãå©ç¨ãã¦ãã' do - Comic.stub(:mylist_where).with(any_args).and_return('') - Comic.should_receive(:mylist_where).with(any_args).exactly(1) - r = Comic.mylist_paginate @author - end - it 'ãã¼ã¸ä»¶æ°10ã®ã¨ãã3ãã¼ã¸ç®ã®ãªãã»ããã¯20ããå§ã¾ã' do - r = Comic.mylist_paginate @author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe 'ä»ä½å®¶ã®ã³ããã¯ä¸è¦§ãã¼ã¸å¶å¾¡ã«æ¼ãã¦' do - before do - Comic.stub(:count).with(any_args).and_return(100) - end - it 'ãã¼ã¸å¶å¾¡ãè¿ã' do - r = Comic.himlist_paginate @other_author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it 'ä»ä½å®¶ã®ã³ããã¯ä¸è¦§ã®åå¾æ¡ä»¶ãå©ç¨ãã¦ãã' do - Comic.stub(:himlist_where).with(any_args).and_return('') - Comic.should_receive(:himlist_where).with(any_args).exactly(1) - r = Comic.himlist_paginate @other_author - end - it 'ãã¼ã¸ä»¶æ°10ã®ã¨ãã3ãã¼ã¸ç®ã®ãªãã»ããã¯20ããå§ã¾ã' do - r = Comic.himlist_paginate @other_author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe 'ä¸è¦§åå¾ãªãã·ã§ã³ã«æ¼ãã¦' do - it '2ã¤ã®é ç®ãå«ãã§ãã' do - r = Comic.list_opt - r.should have(2).items - end - it 'ã¹ãã¼ãªã¼ãå«ãã§ãã' do - r = Comic.list_opt - r.has_key?(:stories).should be_true - end - it 'ã¹ãã¼ãªã¼ã¯ã³ããå«ãã§ãã' do - r = Comic.list_opt - r[:stories].has_key?(:panel).should be_true - end - it 'ä½å®¶ãå«ãã§ãã' do - r = Comic.list_opt - r.has_key?(:author).should be_true - end - end - describe 'jsonä¸è¦§åºåãªãã·ã§ã³ã«æ¼ãã¦' do - before do - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - it 'ã¹ãã¼ãªã¼ãå«ãã§ãã' do - r = Comic.list.to_json Comic.list_json_opt - j = JSON.parse r - i = j.first - i.has_key?('stories').should be_true - end - it 'ã¹ãã¼ãªã¼ã¯ã³ããå«ãã§ãã' do - r = Comic.list.to_json Comic.list_json_opt - j = JSON.parse r - i = j.first - s = i['stories'].first - s.has_key?('panel').should be_true - end - it 'ä½å®¶ãå«ãã§ãã' do - r = Comic.list.to_json Comic.list_json_opt - j = JSON.parse r - i = j.first - i.has_key?('author').should be_true - end - end - - describe 'åä½åå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'åä½åå¾ãªãã·ã§ã³ãå©ç¨ãã¦ãã' do - Comic.stub(:show_opt).with(any_args).and_return({}) - Comic.should_receive(:show_opt).with(any_args).exactly(1) - r = Comic.show @comic.id, @author - end - it 'é²è¦§è¨±å¯ãåãåããã¦ãã' do - Comic.any_instance.stub(:visible?).with(any_args).and_return(true) - Comic.any_instance.should_receive(:visible?).with(any_args).exactly(1) - r = Comic.show @comic.id, @author - end - end - it 'æå®ã®ã³ããã¯ãè¿ã' do - c = Comic.show @comic.id, @author - c.should eq @comic - end - context 'é²è¦§è¨±å¯ãåºãªãã£ãã¨ã' do - it '403Forbiddenä¾å¤ãè¿ã' do - Comic.any_instance.stub(:visible?).and_return(false) - lambda{ - Comic.show @comic.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context 'åå¨ããªãã³ããã¯ãéããã¨ããã¨ã' do - it '404RecordNotFoundä¾å¤ãè¿ã' do - lambda{ - Comic.show 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - - describe 'ç·¨éåå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'åä½åå¾ãªãã·ã§ã³ãå©ç¨ãã¦ãã' do - Comic.stub(:show_opt).with(any_args).and_return({}) - Comic.should_receive(:show_opt).with(any_args).exactly(1) - r = Comic.edit @comic.id, @author - end - it 'ææå¤å®ãåãåããã¦ãã' do - Comic.any_instance.stub(:own?).with(any_args).and_return(true) - Comic.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = Comic.edit @comic.id, @author - end - end - it 'æå®ã®ã³ããã¯ãè¿ã' do - Comic.any_instance.stub(:own?).and_return(true) - c = Comic.edit @comic.id, @author.id - c.should eq @comic - end - context 'ä»äººã®ã³ããã¯ãéããã¨ããã¨ã' do - it '403Forbiddenä¾å¤ãè¿ã' do - Comic.any_instance.stub(:own?).and_return(false) - lambda{ - Comic.edit @comic.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context 'åå¨ããªãã³ããã¯ãéããã¨ããã¨ã' do - it '404RecordNotFoundä¾å¤ãè¿ã' do - lambda{ - Comic.edit 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - describe 'åä½åå¾ãªãã·ã§ã³ã«æ¼ãã¦' do - it 'includeãã¼ãå«ãã§ãã' do - r = Comic.show_opt - r.has_key?(:include).should be_true - end - it '2ã¤ã®é ç®ãå«ãã§ãã' do - r = Comic.show_opt[:include] - r.should have(2).items - end - it 'ä½å®¶ãå«ãã§ãã' do - r = Comic.show_opt[:include] - r.has_key?(:author).should be_true - end - it 'ã¹ãã¼ãªã¼ãå«ãã§ãã' do - r = Comic.show_opt[:include] - r.has_key?(:stories).should be_true - end - it 'ã¹ãã¼ãªã¼ã¯ã³ããå«ãã§ãã' do - r = Comic.show_opt[:include] - r[:stories].has_key?(:panel).should be_true - end - end - describe 'jsonåä½åºåãªãã·ã§ã³ã«æ¼ãã¦' do - before do - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - it 'ã¹ãã¼ãªã¼ãå«ãã§ãã' do - r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt - j = JSON.parse r - i = j - i.has_key?('stories').should be_true - end - it 'ã¹ãã¼ãªã¼ã¯ã³ããå«ãã§ãã' do - r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt - j = JSON.parse r - i = j - s = i['stories'].first - s.has_key?('panel').should be_true - end - it 'ä½å®¶ãå«ãã§ãã' do - r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt - j = JSON.parse r - i = j - i.has_key?('author').should be_true - end - end - - describe 'åé¤ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @other_comic = FactoryGirl.create :comic, :author_id => @author.id - @other_story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @other_comic.id, :panel_id => @panel.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'èªèº«ãåé¤ãã' do - lambda { - r = @comic.destroy_with_story - }.should change(Comic, :count).by(-1) - lambda { - r = Comic.find @comic.id - }.should raise_error - end - it 'èªèº«ã«ãªã³ã¯ãã¦ããã¹ãã¼ãªã¼ããã¹ã¦åé¤ãã' do - lambda { - r = @comic.destroy_with_story - }.should change(Story, :count).by(-1) - lambda { - r = Story.find @story.id - }.should raise_error - end - it 'Trueãè¿ã' do - r = @comic.destroy_with_story - r.should be_true - end - end - context 'åé¤ã«å¤±æããã¨ã' do - before do - Story.any_instance.stub(:destroy).with(any_args).and_return(false) - end - it 'Falseãè¿ã' do - r = @comic.destroy_with_story - r.should be_false - end - it 'ãã¼ã«ããã¯ãã¦ãã' do - lambda { - r = @comic.destroy_with_story - }.should_not change(Comic, :count) - lambda { - r = @comic.destroy_with_story - }.should_not change(Story, :count) - end - end - end -end diff --git a/spec/models/ground_color_spec.rb b/spec/models/ground_color_spec.rb index edf88a30..8debd825 100644 --- a/spec/models/ground_color_spec.rb +++ b/spec/models/ground_color_spec.rb @@ -479,9 +479,9 @@ describe GroundColor do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id @gc = FactoryGirl.create :ground_color, :panel_id => @panel.id end it 'ã³ããå«ãã§ãã' do diff --git a/spec/models/ground_picture_spec.rb b/spec/models/ground_picture_spec.rb index 8230ce01..680b5034 100644 --- a/spec/models/ground_picture_spec.rb +++ b/spec/models/ground_picture_spec.rb @@ -536,9 +536,9 @@ describe GroundPicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id end it 'ã³ããå«ãã§ãã' do diff --git a/spec/models/license_group_spec.rb b/spec/models/license_group_spec.rb index a1c4f70f..685c69a5 100644 --- a/spec/models/license_group_spec.rb +++ b/spec/models/license_group_spec.rb @@ -190,9 +190,9 @@ describe LicenseGroup do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ã©ã¤ã»ã³ã¹ãå«ãã§ãã' do r = LicenseGroup.list.to_json LicenseGroup.list_json_opt @@ -251,9 +251,9 @@ describe LicenseGroup do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ã©ã¤ã»ã³ã¹ãå«ãã§ãã' do r = LicenseGroup.show(@lg.id).to_json LicenseGroup.show_json_opt diff --git a/spec/models/original_picture_spec.rb b/spec/models/original_picture_spec.rb index 54c6d2c3..cc587fc3 100644 --- a/spec/models/original_picture_spec.rb +++ b/spec/models/original_picture_spec.rb @@ -542,9 +542,9 @@ describe OriginalPicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ç´ æãå«ãã§ãã' do r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt @@ -681,9 +681,9 @@ describe OriginalPicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ç´ æãå«ãã§ãã' do r = OriginalPicture.show(@op.id, @artist).to_json OriginalPicture.show_json_opt diff --git a/spec/models/panel_spec.rb b/spec/models/panel_spec.rb index f9aa5722..a1582eed 100644 --- a/spec/models/panel_spec.rb +++ b/spec/models/panel_spec.rb @@ -253,9 +253,9 @@ describe Panel do describe 'é²è¦§è¨±å¯ã«æ¼ãã¦' do before do - @comic = FactoryGirl.create :comic, :author_id => @author.id + @scroll = FactoryGirl.create :scroll, :author_id => @author.id @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end context 'ãªã¼ãã³ã¢ã¼ãã®ã¨ã' do before do @@ -1418,7 +1418,7 @@ describe Panel do describe 'åé¤ã«æ¼ãã¦' do before do - @comic = FactoryGirl.create :comic, :author_id => @author.id + @scroll = FactoryGirl.create :scroll, :author_id => @author.id @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height @sb = @panel.speech_balloons.build( diff --git a/spec/models/resource_picture_spec.rb b/spec/models/resource_picture_spec.rb index 8fd9a97f..fd3433bc 100644 --- a/spec/models/resource_picture_spec.rb +++ b/spec/models/resource_picture_spec.rb @@ -670,9 +670,9 @@ describe ResourcePicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ã©ã¤ã»ã³ã¹ãå«ãã§ãã' do r = ResourcePicture.list.to_json ResourcePicture.list_json_opt @@ -760,9 +760,9 @@ describe ResourcePicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ã©ã¤ã»ã³ã¹ãå«ãã§ãã' do r = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt diff --git a/spec/models/speech_balloon_spec.rb b/spec/models/speech_balloon_spec.rb index 701f1c64..4d63acae 100644 --- a/spec/models/speech_balloon_spec.rb +++ b/spec/models/speech_balloon_spec.rb @@ -532,7 +532,7 @@ describe SpeechBalloon do end context 'DBã«5件ãã£ã¦1ãã¼ã¸ã®ä»¶æ°ã2件ã«å¤ããã¨ãã¦' do before do - @other_sb2 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id + @other_sb2 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100 @other_sb2.build_speech( FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) ) @@ -541,7 +541,7 @@ describe SpeechBalloon do ) @other_sb2.boost @other_sb2.save! - @other_sb3 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id + @other_sb3 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 200 @other_sb3.build_speech( FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) ) @@ -550,7 +550,7 @@ describe SpeechBalloon do ) @other_sb3.boost @other_sb3.save! - @other_sb4 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id + @other_sb4 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 300 @other_sb4.build_speech( FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) ) @@ -559,7 +559,7 @@ describe SpeechBalloon do ) @other_sb4.boost @other_sb4.save! - @other_sb5 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id + @other_sb5 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 400 @other_sb5.build_speech( FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) ) diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb deleted file mode 100644 index 878c2049..00000000 --- a/spec/models/story_spec.rb +++ /dev/null @@ -1,1940 +0,0 @@ -# -*- encoding: utf-8 -*- -require 'spec_helper' -#ã¹ãã¼ãªã¼ -describe Story do - before do - @admin = FactoryGirl.create :admin - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @speech_balloon_template = FactoryGirl.create :speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc", "system_picture_id" => @sp.id, "settings" => '{}' - @writing_format = FactoryGirl.create :writing_format - @user = FactoryGirl.create( :user_yas) - @author = FactoryGirl.create :author, :user_id => @user.id - @artist = FactoryGirl.create :artist_yas, :author_id => @author.id - @other_user = FactoryGirl.create( :user_yas) - @other_author = FactoryGirl.create :author, :user_id => @other_user.id - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - end - - describe 'æ¤è¨¼ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - - context 'ãªã¼ã½ããã¯ã¹ãªãã¼ã¿ã®ã¨ã' do - it 'ä¸éãã¼ã¿ãéã' do - @story.t = 0 - @story.should be_valid - end - it 'ä¸éãã¼ã¿ãéã' do - @story.t = 99999 - @story.should be_valid - end - end - - context 'comic_idãæ¤è¨¼ããã¨ã' do - it 'nullãªã失æãã' do - @story.comic_id = nil - @story.should_not be_valid - end - it 'æ°å¤ã§ãªããã°å¤±æãã' do - @story.comic_id = 'a' - @story.should_not be_valid - end - it 'åå¨ããã³ããã¯ã§ãªããã°å¤±æãã' do - @story.comic_id = 0 - @story.should_not be_valid - end - end - - context 'panel_idãæ¤è¨¼ããã¨ã' do - it 'nullãªã失æãã' do - @story.panel_id = nil - @story.should_not be_valid - end - it 'æ°å¤ã§ãªããã°å¤±æãã' do - @story.panel_id = 'a' - @story.should_not be_valid - end - it 'åå¨ããã³ãã§ãªããã°å¤±æãã' do - @story.panel_id = 0 - @story.should_not be_valid - end - end - - context 'tãæ¤è¨¼ããã¨ã' do - it 'nullãªã失æãã' do - @story.t = nil - @story.should_not be_valid - end - it 'æ°å¤ã§ãªããã°å¤±æãã' do - @story.t = 'a' - @story.should_not be_valid - end - it 'è² ãªã失æãã' do - @story.t = -1 - @story.should_not be_valid - end - end - - context 'author_idãæ¤è¨¼ããã¨ã' do - it 'nullãªã失æãã' do - @story.author_id = nil - @story.should_not be_valid - end - it 'æ°å¤ã§ãªããã°å¤±æãã' do - @story.author_id = 'a' - @story.should_not be_valid - end - it 'åå¨ããä½å®¶ã§ãªããã°å¤±æãã' do - @story.author_id = 0 - @story.should_not be_valid - end - end - context 'å ¨ä½ãæ¤è¨¼ããã¨ã' do - end - end - - describe 'ããã©ã«ãå¤è£å ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - - #dbã®ããã©ã«ãå¤ã0ã ããæ示çã«nilã«ããªãã¨è¿½å ãã§ããªã - it 'tãnilã«ãã' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id - @story.supply_default - @story.t.should be_nil - end - - end - - describe 'ä¸æ¸ãè£å ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - - context 'author_idãè£å ' do - it 'åçç¡ç¨ã§author_idãè£å ãã' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id - @story.author_id = nil - @story.overwrite @author - @story.author_id.should eq @author.id - end - end - - end - - describe 'ææå¤å®ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @comico = FactoryGirl.create :comic, :author_id => @other_author.id - @panelo = FactoryGirl.create :panel, :author_id => @other_author.id - @storyo = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @comico.id, :panel_id => @panelo.id - end - context 'äºåãã§ãã¯ãã' do - it 'èªèº«ã«ãã¼ã«ãªã¹ãããã®ä½å®¶åå¾ãä¾é ¼ãã¦ãã' do - Story.should_receive(:get_author_from_roles).with(any_args).exactly(1) - r = @story.own?([@author]) - end - end - context 'ãã¼ã«å ä½å®¶ãåå¾ã§ããã¨ã' do - before do - end - it 'ãã¼ã«å ä½å®¶ã®idãèªèº«ã®ä½å®¶idã¨ä¸è´ãããªã許å¯ãã' do - Story.stub(:get_author_from_roles).with(any_args).and_return(@author) - r = @story.own?([@author]) - r.should be_true - end - it 'ãã¼ã«å ä½å®¶ã®idãèªèº«ã®ä½å®¶idã¨ä¸è´ããªããªãno' do - Story.stub(:get_author_from_roles).with(any_args).and_return(@other_author) - @story.own?(@other_author).should be_false - end - end - context 'ãã¼ã«å ä½å®¶ãåå¾ã§ããªãã¨ã' do - before do - Story.stub(:get_author_from_roles).with(any_args).and_return(nil) - end - it 'Falseãè¿ã' do - r = @story.own?([@author]) - r.should be_false - end - end - end - - describe 'é²è¦§è¨±å¯ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - context 'ãªã¼ãã³ã¢ã¼ãã®ã¨ã' do - before do - MagicNumber['run_mode'] = 0 - end - it 'èªèº«ã«ã²ã¹ãç¨ãã¼ã«ãã§ãã¯ãåãåãããã¦ãã' do - Story.any_instance.stub(:guest_role_check).and_return(true) - Story.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1) - r = @story.visible?([@author]) - end - it 'ã²ã¹ãç¨ãã¼ã«ãã§ãã¯ã失æããã¨ããfalseãè¿ã' do - Story.any_instance.stub(:guest_role_check).and_return(false) - r = @story.visible?([@author]) - r.should be_false - end - end - context 'ã¯ãã¼ãºãã¢ã¼ãã®ã¨ã' do - before do - MagicNumber['run_mode'] = 1 - end - it 'èªèº«ã«èªè ç¨ãã¼ã«ãã§ãã¯ãåãåãããã¦ãã' do - Story.any_instance.stub(:reader_role_check).and_return(true) - Story.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1) - r = @story.visible?([@author]) - end - it 'èªè ç¨ãã¼ã«ãã§ãã¯ã失æããã¨ããfalseãè¿ã' do - Story.any_instance.stub(:reader_role_check).and_return(false) - r = @story.visible?([@author]) - r.should be_false - end - end - context 'äºåãã§ãã¯ãã' do - before do - MagicNumber['run_mode'] = 1 - Story.any_instance.stub(:reader_role_check).and_return(true) - end - it 'èªèº«ã®ã³ããã¯ã«ææå¤å®ãåãåãããã¦ãã' do - Comic.any_instance.stub(:own?).and_return(true) - Comic.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = @story.visible?([@author]) - end - it 'èªèº«ã®ã³ããã¯ã«é²è¦§è¨±å¯ãåãåãããã¦ãã' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible?).and_return(true) - Comic.any_instance.should_receive(:visible?).with(any_args).exactly(1) - r = @story.visible?([@author]) - end - end - context 'ã¤ã¤ããªãçµããã¨ã' do - before do - MagicNumber['run_mode'] = 1 - Story.any_instance.stub(:reader_role_check).and_return(true) - end - it 'èªåã®ã³ããã¯ã®ã¹ãã¼ãªã¼ãªã許å¯ãã' do - Comic.any_instance.stub(:own?).and_return(true) - Comic.any_instance.stub(:visible).and_return(0) - r = @story.visible?([@author]) - r.should be_true - end - it 'ä»äººã®éå ¬éã³ããã¯ã®ã¹ãã¼ãªã¼ãªã許å¯ããªã' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(0) - r = @story.visible?([@author]) - r.should be_false - end - it 'ä»äººã®ã³ããã¯ã®ã¹ãã¼ãªã¼ã§ãå ¬éãªã許å¯ãã' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(1) - r = @story.visible?([@author]) - r.should be_true - end - end - end - - describe 'ãã¬ã¤ãªã¹ãåå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @panel2 = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0 - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1 - end - context 'offsetè£æ£ã«ã¤ãã¦' do - it 'æååããæ°å¤ã«å¤æããã' do - Story.offset(100, '8').should eq 8 - end - it 'nilã®å ´åã¯0ã«ãªã' do - Story.offset(100).should eq 0 - end - #æ稿ãããã³ãæ°ä»¥ä¸ã®å¤ãæå®ãããã¨ãã¯ãæå¾ã®ã³ãã ãã«ãªã - #æå¾ã®ã³ãã¨ã¯ãã³ãæ°â1ï¼ - it '1件ã®ã¨ããªãã»ãã1ãªã0ã«ãªã' do - Story.offset(1, '1').should eq 0 - end - it '5件ã®ã¨ããªãã»ãã5ãªã4ã«ãªã' do - Story.offset(5, '5').should eq 4 - end - # è² ã®å¤ãæå®ãããã¨ãã¯ãæå¾ã®ã³ãããæ°ãã¦ã³ããé£ã°ãã¦è¡¨ç¤ºããã - #-4ã®ã¨ãã¯ãæå¾ãã4ã¤ã®ã³ãã表示ããã - it '2件ã®ã¨ããªãã»ãã-1ãªã1ã«ãªã' do - Story.offset(2, '-1').should eq 1 - end - it '5件ã®ã¨ããªãã»ãã-2ãªã3ã«ãªã' do - Story.offset(5, '-2').should eq 3 - end - # æçµçãªãè² ã«ãªããªã©ãä¸æ£ãªå¤ãå ¥ã£ãã¨ãã¯0ã¨ãªãã - it '2件ã®ã¨ããªãã»ãã-5ãªã0ã«ãªã' do - Story.offset(2, '-5').should eq 0 - end - end - context 'panel_countè£æ£ã«ã¤ãã¦' do - it 'æååããæ°å¤ã«å¤æããã' do - Story.panel_count(100, '7').should eq 7 - end - it 'nilã®å ´åã¯Story.default_panel_sizeã«ãªã' do - Story.panel_count(100).should eq Story.default_panel_size - end - it '0以ä¸ã®å ´åã¯Story.default_panel_sizeã«ãªã' do - Story.panel_count(100, '0').should eq Story.default_panel_size - end - it 'Story.max_panel_sizeãè¶ ããå ´åã¯Story.max_panel_sizeã«ãªã' do - Story.panel_count(100, '1000').should eq Story.max_panel_size - end - end - it 'ãªã¹ããè¿ã' do - c = Story.play_list @comic, @author - c.should eq [@story] - end - it 'té ã§ä¸¦ãã§ãã' do - #å ¬éã³ããã¯ã®å ¬éã³ãã¯(ä»äººã®ã³ããã¯ã§ãã£ã¦ã)å«ãã§ãã - v = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1 - c = Story.play_list @comic, @author - c.should eq [ @story, v] - end - it 'éå ¬éã®ã³ãã¯å«ãã§ãã' do - h = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel2.id, :t => 1 - c = Story.play_list @comic, @author - c.should eq [ @story, h] - end - context 'DBã«5件ãã£ã¦1ãã¼ã¸ã®ä»¶æ°ã2件ã«å¤ããã¨ãã¦' do - before do - @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1 - @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2 - @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3 - @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4 - end - it 'offset=0ãªãæ«å°¾2件ãè¿ã' do - #æç³»åã§ä¸¦ãã§ãã - c = Story.play_list( @comic, @author, 0, 2) - c.should eq [@story, @story2] - end - it 'offset=2ãªãä¸é2件ãè¿ã' do - c = Story.play_list(@comic, @author, 2, 2) - c.should eq [@story3, @story4] - end - it 'offset=4ãªãå é 1件ãè¿ã' do - c = Story.play_list(@comic, @author, 4, 2) - c.should eq [@story5] - end - end - end - - describe 'ä¸è¦§åå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1 - @hidden_comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0 - end - context 'pageè£æ£ã«ã¤ãã¦' do - it 'æååããæ°å¤ã«å¤æããã' do - Story.page('8').should eq 8 - end - it 'nilã®å ´åã¯1ã«ãªã' do - Story.page().should eq 1 - end - it '0以ä¸ã®å ´åã¯1ã«ãªã' do - Story.page('0').should eq 1 - end - end - context 'page_sizeè£æ£ã«ã¤ãã¦' do - it 'æååããæ°å¤ã«å¤æããã' do - Story.page_size('7').should eq 7 - end - it 'nilã®å ´åã¯Story.default_page_sizeã«ãªã' do - Story.page_size().should eq Story.default_page_size - end - it '0以ä¸ã®å ´åã¯Story.default_page_sizeã«ãªã' do - Story.page_size('0').should eq Story.default_page_size - end - it 'Story.max_page_sizeãè¶ ããå ´åã¯Story.max_page_sizeã«ãªã' do - Story.page_size('1000').should eq Story.max_page_size - end - end - it 'ãªã¹ããè¿ã' do - c = Story.list - c.should eq [@story] - end - it 'æç³»åã§ä¸¦ãã§ãã' do - #å ¬éã³ããã¯ã®Storyã¯(ä»äººã®Storyã§ãã£ã¦ã)å«ãã§ãã - v = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 0, :updated_at => Time.now + 100 - c = Story.list - c.should eq [ v, @story] - end - it 'éå ¬éã®ã¹ãã¼ãªã¼ã¯(èªåã®ã¹ãã¼ãªã¼ã§ãã£ã¦ã)å«ã¾ãªã' do - h = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @hidden_comic.id, :panel_id => @panel.id, :t => 0 - c = Story.list - c.should eq [ @story] - end - context 'DBã«5件ãã£ã¦1ãã¼ã¸ã®ä»¶æ°ã2件ã«å¤ããã¨ãã¦' do - before do - @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100 - @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200 - @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300 - @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400 - end - it 'é常ã¯2件ãè¿ã' do - l = Story.list 1, 2 - l.should have(2).items - end - it 'page=1ãªãæ«å°¾2件ãè¿ã' do - #æç³»åã§ä¸¦ãã§ãã - l = Story.list 1, 2 - l.should eq [@story5, @story4] - end - it 'page=2ãªãä¸é2件ãè¿ã' do - l = Story.list 2, 2 - l.should eq [@story3, @story2] - end - it 'page=3ãªãå é 1件ãè¿ã' do - l = Story.list 3, 2 - l.should eq [@story] - end - end - end - - describe 'èªåã®ã¹ãã¼ãªã¼ä¸è¦§åå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1 - @hcomic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0 - @hpanel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0 - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ä¸è¦§åå¾ãªãã·ã§ã³ãå©ç¨ãã¦ãã' do - Story.stub(:list_opt).with(any_args).and_return({}) - Story.should_receive(:list_opt).with(any_args).exactly(1) - r = Story.mylist @author - end - end - it 'ãªã¹ããè¿ã' do - s = Story.mylist @author - s.should eq [@story] - end - it 'æç³»åã§ä¸¦ãã§ãã' do - ns = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100 - sl = Story.mylist @author - sl.should eq [ns, @story] - end - it 'ä»äººã®ã¹ãã¼ãªã¼ã¯ã³ãã³ããã¯ã¨ãã«å ¬éã§ãå«ã¾ãªã' do - so = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id - sl = Story.mylist @author - sl.should eq [@story] - end - it 'èªåã®ã¹ãã¼ãªã¼ã¯ã³ãã³ããã¯ã¨ãã«éå ¬éã§ãå«ãã§ãã' do - hs = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @hcomic.id, :panel_id => @hpanel.id, :updated_at => Time.now + 100 - sl = Story.mylist @author - sl.should eq [hs, @story] - end - context 'DBã«5件ãã£ã¦1ãã¼ã¸ã®ä»¶æ°ã2件ã«å¤ããã¨ãã¦' do - before do - @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100 - @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200 - @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300 - @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400 - Story.stub(:default_page_size).and_return(2) - end - it 'é常ã¯2件ãè¿ã' do - l = Story.mylist @author, 1, 2 - l.should have(2).items - end - it 'page=1ãªãæ«å°¾2件ãè¿ã' do - #æç³»åã§ä¸¦ãã§ãã - l = Story.mylist @author, 1, 2 - l.should eq [@story5, @story4] - end - it 'page=2ãªãä¸é2件ãè¿ã' do - l = Story.mylist @author, 2, 2 - l.should eq [@story3, @story2] - end - it 'page=3ãªãå é 1件ãè¿ã' do - l = Story.mylist @author, 3, 2 - l.should eq [@story] - end - end - end - - describe 'ä»ä½å®¶ã®ã¹ãã¼ãªã¼ä¸è¦§åå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1 - @other_story = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id - end - it 'ãªã¹ããè¿ã' do - r = Story.himlist @other_author - r.should eq [@other_story] - end - it 'æç³»åã§ä¸¦ãã§ãã' do - ns = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100 - r = Story.himlist @other_author - r.should eq [ns, @other_story] - end - it 'å ¬éã³ããã¯ã®ã¹ãã¼ãªã¼' do - @hcomic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 0 - ns = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @hcomic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100 - r = Story.himlist @other_author - r.should eq [@other_story] - end - context 'DBã«5件ãã£ã¦1ãã¼ã¸ã®ä»¶æ°ã2件ã«å¤ããã¨ãã¦' do - before do - @other_story2 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100 - @other_story3 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 2, :updated_at => Time.now + 200 - @other_story4 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 3, :updated_at => Time.now + 300 - @other_story5 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 4, :updated_at => Time.now + 400 - Story.stub(:default_page_size).and_return(2) - end - it 'é常ã¯2件ãè¿ã' do - l = Story.himlist @other_author, 1, 2 - l.should have(2).items - end - it 'page=1ãªãæ«å°¾2件ãè¿ã' do - #æç³»åã§ä¸¦ãã§ãã - l = Story.himlist @other_author, 1, 2 - l.should eq [@other_story5, @other_story4] - end - it 'page=2ãªãä¸é2件ãè¿ã' do - l = Story.himlist @other_author, 2, 2 - l.should eq [@other_story3, @other_story2] - end - it 'page=3ãªãå é 1件ãè¿ã' do - l = Story.himlist @other_author, 3, 2 - l.should eq [@other_story] - end - end - end - - describe 'ã¹ãã¼ãªã¼ä¸è¦§ãã¼ã¸å¶å¾¡ã«æ¼ãã¦' do - before do - Story.stub(:count).with(any_args).and_return(100) - end - it 'ãã¼ã¸å¶å¾¡ãè¿ã' do - r = Story.list_paginate - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it 'ã¹ãã¼ãªã¼ä¸è¦§ã®åå¾æ¡ä»¶ãå©ç¨ãã¦ãã' do - Story.stub(:list_where).with(any_args).and_return('') - Story.should_receive(:list_where).with(any_args).exactly(1) - r = Story.list_paginate - end - it 'ãã¼ã¸ä»¶æ°10ã®ã¨ãã3ãã¼ã¸ç®ã®ãªãã»ããã¯20ããå§ã¾ã' do - r = Story.list_paginate 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe 'èªåã®ã¹ãã¼ãªã¼ä¸è¦§ãã¼ã¸å¶å¾¡ã«æ¼ãã¦' do - before do - Story.stub(:count).with(any_args).and_return(100) - end - it 'ãã¼ã¸å¶å¾¡ãè¿ã' do - r = Story.mylist_paginate @author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it 'èªåã®ã¹ãã¼ãªã¼ä¸è¦§ã®åå¾æ¡ä»¶ãå©ç¨ãã¦ãã' do - Story.stub(:mylist_where).with(any_args).and_return('') - Story.should_receive(:mylist_where).with(any_args).exactly(1) - r = Story.mylist_paginate @author - end - it 'ãã¼ã¸ä»¶æ°10ã®ã¨ãã3ãã¼ã¸ç®ã®ãªãã»ããã¯20ããå§ã¾ã' do - r = Story.mylist_paginate @author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe 'ä»ä½å®¶ã®ã¹ãã¼ãªã¼ä¸è¦§ãã¼ã¸å¶å¾¡ã«æ¼ãã¦' do - before do - Story.stub(:count).with(any_args).and_return(100) - end - it 'ãã¼ã¸å¶å¾¡ãè¿ã' do - r = Story.himlist_paginate @other_author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it 'ä»ä½å®¶ã®ã¹ãã¼ãªã¼ä¸è¦§ã®åå¾æ¡ä»¶ãå©ç¨ãã¦ãã' do - Story.stub(:himlist_where).with(any_args).and_return('') - Story.should_receive(:himlist_where).with(any_args).exactly(1) - r = Story.himlist_paginate @other_author - end - it 'ãã¼ã¸ä»¶æ°10ã®ã¨ãã3ãã¼ã¸ç®ã®ãªãã»ããã¯20ããå§ã¾ã' do - r = Story.himlist_paginate @other_author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe 'listé¢é£ãã¼ãã«ãã·ã§ã³ã«æ¼ãã¦' do - it '3ã¤ã®é ç®ãå«ãã§ãã' do - r = Story.list_opt - r.should have(3).items - end - it 'ã³ããã¯ãå«ãã§ãã' do - r = Story.list_opt - r.has_key?(:comic).should be_true - end - it 'ã³ããã¯ã¯ä½å®¶ãå«ãã§ãã' do - r = Story.list_opt - r[:comic].has_key?(:author).should be_true - end - it 'ä½å®¶ãå«ãã§ãã' do - r = Story.list_opt - r.has_key?(:author).should be_true - end - it 'ã³ããå«ãã§ãã' do - r = Story.list_opt - r.has_key?(:panel).should be_true - end - it 'ã³ãã¯ä½å®¶ãå«ãã§ãã' do - r = Story.list_opt - r[:panel].has_key?(:author).should be_true - end - it 'ã³ãã¯ã³ãçµµãå«ãã§ãã' do - r = Story.list_opt - r[:panel].has_key?(:panel_pictures).should be_true - end - it 'ã³ãçµµã¯å®ç´ æãå«ãã§ãã' do - r = Story.list_opt - r[:panel][:panel_pictures].has_key?(:picture).should be_true - end - it 'å®ç´ æã¯çµµå¸«ãå«ãã§ãã' do - r = Story.list_opt - r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true - end - it 'å®ç´ æã¯ã©ã¤ã»ã³ã¹ãå«ãã§ãã' do - r = Story.list_opt - r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true - end - it 'ã³ãã¯ãããã·ãå«ãã§ãã' do - r = Story.list_opt - r[:panel].has_key?(:speech_balloons).should be_true - end - it 'ãããã·ã¯ãããã·æ ãå«ãã§ãã' do - r = Story.list_opt - r[:panel][:speech_balloons].has_key?(:balloon).should be_true - end - it 'ãããã·ã¯ã»ãªããå«ãã§ãã' do - r = Story.list_opt - r[:panel][:speech_balloons].has_key?(:speech).should be_true - end - end - describe 'jsonä¸è¦§åºåãªãã·ã§ã³ã«æ¼ãã¦' do - end - - describe 'åä½åå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'åä½åå¾ãªãã·ã§ã³ãå©ç¨ãã¦ãã' do - Story.stub(:show_opt).with(any_args).and_return({}) - Story.should_receive(:show_opt).with(any_args).exactly(1) - r = Story.show @story.id, @author - end - it 'é²è¦§è¨±å¯ãåãåããã¦ãã' do - Story.any_instance.stub(:visible?).with(@author).and_return(true) - Story.any_instance.should_receive(:visible?).with(@author).exactly(1) - r = Story.show @story.id, @author - end - end - it 'æå®ã®ã¹ãã¼ãªã¼ãè¿ã' do - l = Story.show @story.id, @author - l.should eq @story - end - context 'ä»äººã®ã¹ãã¼ãªã¼ãéããã¨ããã¨ã' do - it '403Forbiddenä¾å¤ãè¿ã' do - Story.any_instance.stub(:visible?).with(@other_author).and_return(false) - lambda{ - Story.show @story.id, @other_author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context 'åå¨ããªãã¹ãã¼ãªã¼ãéããã¨ããã¨ã' do - it '404RecordNotFoundä¾å¤ãè¿ã' do - lambda{ - Story.show 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - - describe 'ç·¨éåå¾ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'åä½åå¾ãªãã·ã§ã³ãå©ç¨ãã¦ãã' do - Story.stub(:show_opt).with(any_args).and_return({}) - Story.should_receive(:show_opt).with(any_args).exactly(1) - r = Story.edit @story.id, @author - end - it 'ææå¤å®ãåãåããã¦ãã' do - Story.any_instance.stub(:own?).with(any_args).and_return(true) - Story.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = Story.edit @story.id, @author - end - end - it 'æå®ã®ã¹ãã¼ãªã¼ãè¿ã' do - l = Story.edit @story.id, @author - l.should eq @story - end - context 'ä»äººã®ã¹ãã¼ãªã¼ãéããã¨ããã¨ã' do - it '403Forbiddenä¾å¤ãè¿ã' do - Story.any_instance.stub(:own?).and_return(false) - lambda{ - Story.edit @story.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context 'åå¨ããªãã¹ãã¼ãªã¼ãéããã¨ããã¨ã' do - it '404RecordNotFoundä¾å¤ãè¿ã' do - lambda{ - Story.edit 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - - describe 'åä½åå¾ãªãã·ã§ã³ã«æ¼ãã¦' do - it 'includeãã¼ãå«ãã§ãã' do - r = Story.show_opt - r.has_key?(:include).should be_true - end - it '3ã¤ã®é ç®ãå«ãã§ãã' do - r = Story.show_opt[:include] - r.should have(3).items - end - it 'ã³ããã¯ãå«ãã§ãã' do - r = Story.show_opt[:include] - r.has_key?(:comic).should be_true - end - it 'ã³ããã¯ã¯ä½å®¶ãå«ãã§ãã' do - r = Story.show_opt[:include] - r[:comic].has_key?(:author).should be_true - end - it 'ä½å®¶ãå«ãã§ãã' do - r = Story.show_opt[:include] - r.has_key?(:author).should be_true - end - it 'ã³ããå«ãã§ãã' do - r = Story.show_opt[:include] - r.has_key?(:panel).should be_true - end - it 'ã³ãã¯ä½å®¶ãå«ãã§ãã' do - r = Story.show_opt[:include] - r[:panel].has_key?(:author).should be_true - end - it 'ã³ãã¯ã³ãçµµãå«ãã§ãã' do - r = Story.show_opt[:include] - r[:panel].has_key?(:panel_pictures).should be_true - end - it 'ã³ãçµµã¯å®ç´ æãå«ãã§ãã' do - r = Story.show_opt[:include] - r[:panel][:panel_pictures].has_key?(:picture).should be_true - end - it 'å®ç´ æã¯çµµå¸«ãå«ãã§ãã' do - r = Story.show_opt[:include] - r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true - end - it 'å®ç´ æã¯ã©ã¤ã»ã³ã¹ãå«ãã§ãã' do - r = Story.show_opt[:include] - r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true - end - it 'ã³ãã¯ãããã·ãå«ãã§ãã' do - r = Story.show_opt[:include] - r[:panel].has_key?(:speech_balloons).should be_true - end - it 'ãããã·ã¯ãããã·æ ãå«ãã§ãã' do - r = Story.show_opt[:include] - r[:panel][:speech_balloons].has_key?(:balloon).should be_true - end - it 'ãããã·ã¯ã»ãªããå«ãã§ãã' do - r = Story.show_opt[:include] - r[:panel][:speech_balloons].has_key?(:speech).should be_true - end - end - describe 'jsonåä½åå¾ãªãã·ã§ã³ã«æ¼ãã¦' do - end - - describe 'ã¹ãã¼ãªã¼ã®jsonåºåã«æ¼ãã¦' do - before do - #ã³ããä½æãã¦ããã - @panel = FactoryGirl.create :panel, :author_id => @author.id - @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height - @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id - @speech = @sb.build_speech( - FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) - ) - @balloon = @sb.build_balloon( - FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id) - ) - @sb.boost - @sb.save! - @gc = @panel.ground_colors.create( - FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id) - ) - @gp = @panel.ground_pictures.create( - FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id) - ) - @panel.reload - @comic = FactoryGirl.create :comic, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - context 'äºåãã§ãã¯ãã' do - before do - Panel.any_instance.stub(:elements).and_return('{}') - end - it 'ã³ãè¦ç´ ã®jsonåºåãä¾é ¼ãã¦ãã' do - Panel.any_instance.stub(:visible?).with(any_args).and_return(true) - Panel.any_instance.should_receive(:elements).with(any_args).exactly(1) - r = @story.story_as_json @author - end - end - it 'json textãè¿ãã¦ãã' do - r = JSON.parse @story.story_as_json(@author) - r.is_a?(Hash).should be_true - end - it 'comic,author,panel,ã³ãè¦ç´ ãå«ãã§ãã' do - r = JSON.parse @story.story_as_json(@author) - r.has_key?('comic').should be_true - r['comic'].has_key?('author').should be_true - r.has_key?('author').should be_true - r.has_key?('panel').should be_true - r['panel'].has_key?('author').should be_true - end - context 'ã³ãé²è¦§è¨±å¯ã®ã¨ã' do - before do - Panel.any_instance.stub(:visible?).with(any_args).and_return(true) - end - it 'ã³ãè¦ç´ ã«ã³ãè¦ç´ ã追å ãã¦ãã' do - r = JSON.parse @story.story_as_json(@author) - r['panel'].has_key?('elements').should be_true - r['panel']['elements'].should_not be_empty - end - end - context 'ã³ãé²è¦§ä¸è¨±å¯ã®ã¨ã' do - before do - Panel.any_instance.stub(:visible?).with(any_args).and_return(false) - end - it 'ã³ãè¦ç´ ã«ãã¼ã¿ãå«ã¾ããªã' do - r = JSON.parse @story.story_as_json(@author) - r['panel'].has_key?('elements').should be_false - end - end - end - - describe 'ã¹ãã¼ãªã¼ãªã¹ãã®jsonåºåã«æ¼ãã¦' do - before do - @panel = FactoryGirl.create :panel, :author_id => @author.id - @comic = FactoryGirl.create :comic, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - Story.any_instance.stub(:story_as_json).with(@author).and_return('{"s": 5}') - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ãªã¼ã®jsonåºåãä¾é ¼ãã¦ãã' do - Story.any_instance.should_receive(:story_as_json).with(@author).exactly(1) - r = Story.list_as_json_text [@story], @author - end - end - it 'json textãè¿ãã¦ãã' do - r = Story.list_as_json_text [@story], @author - j = JSON.parse r - j.is_a?(Array).should be_true - end - it 'ã¹ãã¼ãªã¼ãå«ãã§ãã' do - r = Story.list_as_json_text [@story], @author - j = JSON.parse r - j.first.has_key?('s').should be_true - end - end - - describe 'ã©ã¤ã»ã³ã¹ç´ æã«æ¼ãã¦' do - before do - #ã³ããä½æãã¦ããã - @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p2 = FactoryGirl.create :picture, :original_picture_id => @op2.id, :license_id => @license.id, :artist_id => @artist.id - @rp2 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op2.id, :picture_id => @p2.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 0, :width => @p.width, :height => @p.height, :picture_id => @p.id - @panel.reload - @panel2 = FactoryGirl.create :panel, :author_id => @author.id - @pp2= FactoryGirl.create :panel_picture, :panel_id => @panel2.id, :t => 0, :width => @p2.width, :height => @p2.height, :picture_id => @p2.id - @panel2.reload - - @comic = FactoryGirl.create :comic, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel2.id - end - context 'äºåãã§ãã¯' do - end - context 'ã¤ã¤ããªãçµããã¨ã' do - end - it 'é£æ³é å(å¤ã¯å®ç´ æããã¼ã¯å®ç´ æid)ãè¿ãã¦ãã' do - r = Story.licensed_pictures [@story, @story2] - r.is_a?(Hash).should be_true - r.should have(2).items - r[@pp.picture_id].should eq @p - r[@pp2.picture_id].should eq @p2 - end - context 'ã³ããåé¤ããã¦ããã¨ãã' do - before do - @panel2.destroy - end - it 'åé¤ããã¦ããã³ãã¯ç¡è¦ãã' do - r = Story.licensed_pictures [@story, @story2] - r.is_a?(Hash).should be_true - r.should have(1).items - r[@pp.picture_id].should eq @p - r[@pp2.picture_id].should be_nil - end - end - end - - describe 'tè£å å¤ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - - context 'ã³ããã¯åã®ã³ããªã' do - it '0ãè£å å¤ã¨ãã' do - @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @story.t = nil - r = Story.new_t @story.comic_id - r.should eq 0 - end - end - context 'ã³ããã¯ã«ä¸åã³ããããã¨ã' do - it '1ãè£å å¤ã¨ãã' do - FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 0 - @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @story.t = nil - r = Story.new_t @story.comic_id - r.should eq 1 - end - end - context 'ã³ããã¯ã«2åã³ããããã¨ã' do - it '2ãè£å å¤ã¨ãã' do - FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 0 - FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1 - @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @story.t = nil - r = Story.new_t @story.comic_id - r.should eq 2 - end - end - end - describe 'ã·ãªã¢ã©ã¤ãºãã§ãã¯ã«æ¼ãã¦' do - context 'ã¤ã¤ããªãçµããã¨ã' do - it '0ããã·ãªã¢ã©ã¤ãºããã¦ãããªãTrueãè¿ã' do - r = Story.serial? [0, 1, 2] - r.should be_true - end - it 'è¦ãç®ã¯ã·ãªã¢ã©ã¤ãºããã¦ãªãã¦ãã½ã¼ãçµæãç¡äºãªãtrueãè¿ã' do - r = Story.serial? [0, 2, 1] - r.should be_true - end - it 'è¦ãç®ã¯ã·ãªã¢ã©ã¤ãºããã¦ãªãã¦ãã½ã¼ãçµæãç¡äºãªãtrueãè¿ã' do - r = Story.serial? [ 2, 1, 4, 3, 0] - r.should be_true - end - end - context 'ç°å¸¸ãªã¨ã' do - it '0ããå§ã¾ããªããªãFalseãè¿ã' do - r = Story.serial? [1, 2, 3] - r.should be_false - end - it 'é£ç¶ãã¦ããªããªãFalseãè¿ã' do - r = Story.serial? [0, 1, 2, 4] - r.should be_false - end - it 'é£ç¶ãã¦ããªããªãFalseãè¿ã' do - r = Story.serial? [0, 1, 2, 4, 5] - r.should be_false - end - end - end - describe 'tåéã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @c2story = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ã¹ãã¼ãªã¼ããåä¸ã³ããã¯ã®tã ããåéãã¦ãã' do - r = Story.collect_t @story - r.should eq [0] - end - end - context 'è¤æ°ã³ãã®ã¨ã' do - it 'ã¹ãã¼ãªã¼ããåä¸ã³ããã¯ã®tã ããåéãã¦ãã' do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - r = Story.collect_t @story - r.sort.should eq [0, 1] - end - end - context 'è¤æ°ã³ãã§ã¨ã½ã®ã³ããã¯ãæ··ãã£ã¦ããã¨ã' do - it 'ã¹ãã¼ãªã¼ããåä¸ã³ããã¯ã®tã ããåéãã¦ãã' do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - r = Story.collect_t @story - r.sort.should eq [0, 1] - end - end - end - describe 'tãã§ãã¯ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'tåéãä¾é ¼ãã¦ãã' do - Story.should_receive(:collect_t).with(any_args).exactly(1) - Story.stub(:collect_t).with(any_args).and_return([]) - Story.stub(:serial?).with(any_args).and_return(true) - r = Story.validate_t @story - end - it 'åéããtãã·ãªã¢ã©ã¤ãºãã§ãã¯ä¾é ¼ãã¦ãã' do - Story.stub(:collect_t).with(any_args).and_return([]) - Story.should_receive(:serial?).with(any_args).exactly(1) - Story.stub(:serial?).with(any_args).and_return(true) - r = Story.validate_t @story - end - end - #å®ãã¼ã¿ã§ãã§ã㯠- #ä¾é ¼ãã§ãã¯ã ãã§ã¯ä¸å®ãªã®ã§æä½éã®ãã§ãã¯ã - context 'æ°è¦ã®ã¨ã' do - it 'ä¸ä»¶ã ãã§æ£å¸¸ééãã¦ãã' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0 - r = Story.validate_t @story - r.should be_true - end - end - context 'æ¢åã®ã¨ã' do - it '2件ç®ãä½ã£ã¦ãæ£å¸¸ééãã¦ãã' do - @story = FactoryGirl.create :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0 - @story2 = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 1 - r = Story.validate_t @story2 - r.should be_true - end - end - end - describe 'æ¿å ¥ã·ããã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - context 'ä¾é ¼ãã§ãã¯' do - #ãã¼ãã«ã空ã§0ã«æ¿å ¥ - it 'Updateãä¾é ¼ãã¦ãã' do - Story.stub(:update_all).with(any_args) - Story.should_receive(:update_all).with(any_args).exactly(1) - @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story.insert_shift - end - end - context 'ãã¼ãã«ã«1件(t:0)ã§0ã«æ¿å ¥ããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it 'æ¢åã®è¡ã1ã«ã·ãããã¦ãã' do - @story2.insert_shift - l = Story.find :all - l.first.t.should eq 1 - end - it 'ããããæ¿å ¥ããt(0)ãæ¬ çªã«ãªã£ã¦ãã' do - @story2.insert_shift - l = Story.find(:all).map {|s| s.t } - l.include?(0).should_not be_true - end - end - context 'ãã¼ãã«ã«2件(t:0,1)ã§1ã«æ¿å ¥ããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it 'æ¢åã®t1ã2ã«ã·ãããã¦ããããæ¿å ¥ããt(1)ãæ¬ çªã«ãªã£ã¦ãã' do - @story3.insert_shift - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 2] - end - end - context 'ãã¼ãã«ã«5件(t:0,1,2,3,4)ã§2ã«æ¿å ¥ããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it 'æ¢åã®t1ã2ã«ã·ãããã¦ããããæ¿å ¥ããt(1)ãæ¬ çªã«ãªã£ã¦ãã' do - @story6.insert_shift - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 1, 3, 4, 5] - end - end - context 'å ã»ã©ã®ã±ã¼ã¹+ä»ã®ã³ããã¯1件ã§æ¿å ¥ããã¨ã' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it 'æ¢åã®t1ã2ã«ã·ãããã¦ããããæ¿å ¥ããt(1)ãæ¬ çªã«ãªã£ã¦ãã' do - @story6.insert_shift - l = Story.find(:all, :conditions => ['comic_id = ?', @comic.id]).map {|s| s.t } - l.sort.should eq [0, 1, 3, 4, 5] - end - it 'ä»ã®ã³ããã¯ã«å½±é¿ããªã' do - ot = @storyc2.t - @story6.insert_shift - @storyc2.reload - @storyc2.t.should eq ot - end - end - end - describe 'å°ãªãæ¹ã«ç§»åã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - context 'ä¾é ¼ãã§ãã¯' do - it 'Updateãä¾é ¼ãã¦ãã' do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:update_all).with(any_args) - Story.should_receive(:update_all).with(any_args).exactly(1) - ot = @story2.t - @story2.t = 0 - @story2.lesser_shift ot - end - end - context 'ãã¼ãã«ã«2件(t:0,1)ã§1ã0ã«ç§»åããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = 0 - end - it 'æ¢åã®t0ã1ã«ã·ãããã¦ããããæ¿å ¥ããt(0)ãæ¬ çªã«ãªã£ã¦ãã' do - #移åããããè¡ã¯ãã®ã¾ã¾æ®ã - @story2.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [1, 1] - end - it 'æ¢åã®t0ã1ã«ã·ãããã¦ãã' do - @story2.lesser_shift @ot - @story.reload - @story.t.should eq 1 - end - end - context 'ãã¼ãã«ã«3件(t:0,1,2)ã§2ã1ã«ç§»åããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story3.t - @story3.t = 1 - end - it 'æ¢åã®t1ã2ã«ã·ãããã¦ããããæ¿å ¥ããt(1)ãæ¬ çªã«ãªã£ã¦ãã' do - #移åããããè¡ã¯ãã®ã¾ã¾æ®ã - @story3.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 2, 2] - end - it 'æ¢åã®t1ã2ã«ã·ãããã¦ãã' do - @story3.lesser_shift @ot - @story2.reload - @story2.t.should eq 2 - end - end - context 'ãã¼ãã«ã«5件(t:0,1,2,3,4)ã§3ã1ã«ç§»åããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story4.t - @story4.t = 1 - end - it 'ããããæ¿å ¥ããt(1)ãæ¬ çªã«ãªã£ã¦ãã' do - #移åããããè¡ã¯ãã®ã¾ã¾æ®ã - @story4.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 2, 3, 3, 4] - end - it 'æ¢åã®t0ã«ã¯å¤åããªã' do - @story4.lesser_shift @ot - @story.reload - @story.t.should eq 0 - end - it 'æ¢åã®t4ã«ã¯å¤åããªã' do - @story4.lesser_shift @ot - @story5.reload - @story5.t.should eq 4 - end - it 'æ¢åã®t1ã2ã«ã·ãããã¦ãã' do - @story4.lesser_shift @ot - @story2.reload - @story2.t.should eq 2 - end - it 'æ¢åã®t2ã3ã«ã·ãããã¦ãã' do - @story4.lesser_shift @ot - @story3.reload - @story3.t.should eq 3 - end - end - context 'å ã»ã©ã®ã±ã¼ã¹+ä»ã®ã³ããã¯1件ã§æ¿å ¥ããã¨ã' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story4.t - @story4.t = 1 - end - it 'ããããæ¿å ¥ããt(1)ãæ¬ çªã«ãªã£ã¦ãã' do - @story4.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0, 2, 3, 3, 4] - end - it 'æ¢åã®t0ã«ã¯å¤åããªã' do - @story4.lesser_shift @ot - @story.reload - @story.t.should eq 0 - end - it 'æ¢åã®t4ã«ã¯å¤åããªã' do - @story4.lesser_shift @ot - @story5.reload - @story5.t.should eq 4 - end - it 'æ¢åã®t1ã2ã«ã·ãããã¦ãã' do - @story4.lesser_shift @ot - @story2.reload - @story2.t.should eq 2 - end - it 'æ¢åã®t2ã3ã«ã·ãããã¦ãã' do - @story4.lesser_shift @ot - @story3.reload - @story3.t.should eq 3 - end - it 'ä»ã®ã³ããã¯ã«å½±é¿ããªã' do - @story4.lesser_shift @ot - @storyc2.reload - @storyc2.t.should eq 0 - end - end - #ä¾å¤ã±ã¼ã¹ã - #è² ã®ã¨ãã¯0ã¨ãã¦æ£å¸¸æ±ã - context 'ãã¼ãã«ã«2件(t:0,1)ã§1ã-1ã«ç§»åããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = -1 - end - it 'æ¢åã®t0ã1ã«ã·ãããã¦ããããæ¿å ¥ããt(0)ãæ¬ çªã«ãªã£ã¦ãã' do - #移åããããè¡ã¯ãã®ã¾ã¾æ®ã - @story2.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [1, 1] - end - it 'æ¢åã®t0ã1ã«ã·ãããã¦ãã' do - @story2.lesser_shift @ot - @story.reload - @story.t.should eq 1 - end - it 'æ¢åã®t1ã¯0ã«è£æ£ããã¦ãã' do - @story2.lesser_shift @ot - @story2.t.should eq 0 - end - end - end - describe '大ããæ¹ã«ç§»åã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - context 'ä¾é ¼ãã§ãã¯' do - it 'Updateãä¾é ¼ãã¦ãã' do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:update_all).with(any_args) - Story.should_receive(:update_all).with(any_args).exactly(1) - ot = @story.t - @story.t = 1 - @story.higher_shift ot - end - end - context 'ãã¼ãã«ã«2件(t:0,1)ã§0ã1ã«ç§»åããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story.t - @story.t = 1 - end - it 'æ¢åã®t1ã0ã«ã·ãããã¦ããããæ¿å ¥ããt(1)ãæ¬ çªã«ãªã£ã¦ãã' do - #移åããããè¡ã¯ãã®ã¾ã¾æ®ã - @story.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0] - end - it 'æ¢åã®t1ã0ã«ã·ãããã¦ãã' do - @story.higher_shift @ot - @story2.reload - @story2.t.should eq 0 - end - end - context 'ãã¼ãã«ã«3件(t:0,1,2)ã§0ã1ã«ç§»åããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story.t - @story.t = 1 - end - it 'æ¢åã®t1ã0ã«ã·ãããã¦ããããæ¿å ¥ããt(1)ãæ¬ çªã«ãªã£ã¦ãã' do - #移åããããè¡ã¯ãã®ã¾ã¾æ®ã - @story.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0, 2] - end - it 'æ¢åã®t1ã0ã«ã·ãããã¦ãã' do - @story.higher_shift @ot - @story2.reload - @story2.t.should eq 0 - end - end - context 'ãã¼ãã«ã«5件(t:0,1,2,3,4)ã§1ã3ã«ç§»åããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = 3 - end - it 'ããããæ¿å ¥ããt(3)ãæ¬ çªã«ãªã£ã¦ãã' do - #移åããããè¡ã¯ãã®ã¾ã¾æ®ã - @story2.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 1, 1, 2, 4] - end - it 'æ¢åã®t0ã«ã¯å¤åããªã' do - @story2.higher_shift @ot - @story.reload - @story.t.should eq 0 - end - it 'æ¢åã®t4ã«ã¯å¤åããªã' do - @story2.higher_shift @ot - @story5.reload - @story5.t.should eq 4 - end - it 'æ¢åã®t2ã1ã«ã·ãããã¦ãã' do - @story2.higher_shift @ot - @story3.reload - @story3.t.should eq 1 - end - it 'æ¢åã®t3ã2ã«ã·ãããã¦ãã' do - @story2.higher_shift @ot - @story4.reload - @story4.t.should eq 2 - end - end - context 'å ã»ã©ã®ã±ã¼ã¹+ä»ã®ã³ããã¯1件ã§æ¿å ¥ããã¨ã' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = 3 - end - it 'ããããæ¿å ¥ããt(3)ãæ¬ çªã«ãªã£ã¦ãã' do - #移åããããè¡ã¯ãã®ã¾ã¾æ®ã - @story2.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0, 1, 1, 2, 4] - end - it 'æ¢åã®t0ã«ã¯å¤åããªã' do - @story2.higher_shift @ot - @story.reload - @story.t.should eq 0 - end - it 'æ¢åã®t4ã«ã¯å¤åããªã' do - @story2.higher_shift @ot - @story5.reload - @story5.t.should eq 4 - end - it 'æ¢åã®t2ã1ã«ã·ãããã¦ãã' do - @story2.higher_shift @ot - @story3.reload - @story3.t.should eq 1 - end - it 'æ¢åã®t3ã2ã«ã·ãããã¦ãã' do - @story2.higher_shift @ot - @story4.reload - @story4.t.should eq 2 - end - it 'ä»ã®ã³ããã¯ã«å½±é¿ããªã' do - @story2.higher_shift @ot - @storyc2.reload - @storyc2.t.should eq 0 - end - end - #ä¾å¤ã±ã¼ã¹ã - #maxè¶ ããã¨ãã¯maxã¨ãã¦æ£å¸¸æ±ã - context 'ãã¼ãã«ã«2件(t:0,1)ã§0ã2ã«ç§»åããã¨ã' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story.t - @story.t = 2 - end - it 'æ¢åã®t1ã0ã«ã·ãããã¦ããããæ¿å ¥ããt(1)ãæ¬ çªã«ãªã£ã¦ãã' do - #移åããããè¡ã¯ãã®ã¾ã¾æ®ã - @story.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0] - end - it 'æ¢åã®t1ã0ã«ã·ãããã¦ãã' do - @story.higher_shift @ot - @story2.reload - @story2.t.should eq 0 - end - it 'æ¢åã®t0ã¯1ã«è£æ£ããã¦ãã' do - @story.higher_shift @ot - @story.t.should eq 1 - end - end - end - describe 'å ¥ãæ¿ãã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'æ°tãæ§tããå°ããã¨ã' do - it 'å°ãªãæ¹ã«ç§»åãä¾é ¼ãã¦ãã' do - Story.any_instance.stub(:lesser_shift).with(any_args) - Story.any_instance.should_receive(:lesser_shift).with(any_args).exactly(1) - ot = @story2.t - @story2.t = 0 - @story2.update_shift ot - end - end - context 'æ°tãæ§tãã大ããã¨ã' do - it '大ããæ¹ã«ç§»åãä¾é ¼ãã¦ãã' do - Story.any_instance.stub(:higher_shift).with(any_args) - Story.any_instance.should_receive(:higher_shift).with(any_args).exactly(1) - ot = @story.t - @story.t = 1 - @story.update_shift ot - end - end - end - describe 'é åºå ¥ãæ¿ãã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - context 'ãªãã¸ã§ã¯ããæ°è¦ã§tã空ã®ã¨ã' do - it 'æ«å°¾è¿½å ã¨ãã¦tãè£å ä¾é ¼ãã¦ãã' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:new_t).with(any_args).and_return(0) - Story.should_receive(:new_t).with(any_args).exactly(1) - @story.t = nil - r = @story.rotate - end - end - context 'ãªãã¸ã§ã¯ããæ°è¦ã§tãè¨å®ããã¦ããã¨ã' do - it 'æ¿å ¥è¿½å ã¨ãã¦æ¿å ¥ã·ãããä¾é ¼ãã¦ãã' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.any_instance.stub(:insert_shift).with(any_args) - Story.any_instance.should_receive(:insert_shift).with(any_args).exactly(1) - @story.t = 0 - r = @story.rotate - end - end - context 'ãªãã¸ã§ã¯ããæ°è¦ã§ãªãtãè¨å®ããã¦ããã¨ã' do - it 'ã³ã移åã¨ãã¦å ¥ãæ¿ããä¾é ¼ãã¦ãã' do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.any_instance.stub(:update_shift).with(any_args) - Story.any_instance.should_receive(:update_shift).with(1).exactly(1) - @story2.t = 0 - r = @story.rotate 1 - end - end - context 'ãªãã¸ã§ã¯ããæ°è¦ã§ãªãtã空ã®ã¨ã' do - it 'å ¥ãæ¿ããã·ããããããtã空ã®ã¾ã¾ã«ãã¦ãã' do - #çµæãtã«æ¬ çªãçãã¦ã·ãªã¢ã©ã¤ãºãã§ãã¯ã§ã²ã£ããã - end - end - end - describe 'ç·¨é許å¯ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.build :story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'trueãè¿ã' do - r = @story.allow? - r.should be_true - end - end - context 'ã³ããã¯ã§å¼ã£ãããã¨ã' do - it 'falseãè¿ã' do - Panel.any_instance.stub(:usable?).with(any_args).and_return(true) - Comic.any_instance.stub(:own?).with(any_args).and_return(false) - r = @story.allow? - r.should be_false - end - end - context 'ã³ãã§å¼ã£ãããã¨ã' do - it 'falseãè¿ã' do - Comic.any_instance.stub(:own?).with(any_args).and_return(true) - Panel.any_instance.stub(:usable?).with(any_args).and_return(false) - r = @story.allow? - r.should be_false - end - end - context 'ã³ããã¯ã¾ãã¯ã³ããæå®ããã¦ããªãã£ãã¨ã' do - it 'nilãè¿ã' do - Comic.any_instance.stub(:own?).with(any_args).and_return(true) - @story.panel_id = nil - r = @story.allow? - r.should eq nil - end - it 'nilãè¿ã' do - Panel.any_instance.stub(:usable?).with(any_args).and_return(true) - @story.comic_id = nil - r = @story.allow? - r.should eq nil - end - end - end - describe 'ä¿åã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.build :story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'ç·¨é許å¯ãã§ãã¯ãä¾é ¼ãã¦ãã' do - Story.any_instance.stub(:allow?).with(any_args).and_return(true) - Story.any_instance.should_receive(:allow?).with(any_args).exactly(1) - r = @story.store - end - it 'é åºå ¥ãæ¿ããä¾é ¼ãã¦ãã' do - Story.any_instance.stub(:rotate).with(any_args).and_return(0) - Story.any_instance.should_receive(:rotate).with(any_args).exactly(1) - Story.any_instance.stub(:save).with(any_args).and_return(true) - Story.stub(:validate_t).with(any_args).and_return(true) - r = @story.store - end - it 'ä¿åãä¾é ¼ãã¦ãã' do - Story.stub(:new_t).with(any_args).and_return(0) - Story.any_instance.stub(:save).with(any_args).and_return(true) - Story.any_instance.should_receive(:save).with(any_args).exactly(1) - Story.stub(:validate_t).with(any_args).and_return(true) - r = @story.store - end - it 'tã®ã·ãªã¢ã©ã¤ãºãã§ãã¯ãä¾é ¼ãã¦ãã' do - Story.stub(:new_t).with(any_args).and_return(0) - Story.any_instance.stub(:save).with(any_args).and_return(true) - Story.stub(:validate_t).with(any_args).and_return(true) - Story.should_receive(:validate_t).with(any_args).exactly(1) - r = @story.store - end - end - #å ¥ãæ¿ããã¹ãã¨åããã¹ããå®æ½ããã¡ãã¯ã·ããã ãã§ãªãæ¬å°ãæ´æ°ããã¦ãã - context 'ãã¼ãã«ã«5件(t:0,1,2,3,4)+ä»ã®ã³ããã¯1件ã§2ã«æ¿å ¥ããã¨ã' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it 'æ¢åã®t0ã«ã¯å¤åããªã' do - @story6.store - @story.reload - @story.t.should eq 0 - end - it 'æ¢åã®t1ã«ã¯å¤åããªã' do - @story6.store - @story2.reload - @story2.t.should eq 1 - end - it 'æ¢åã®t2ã3ã«ã·ãããã¦ãã' do - @story6.store - @story3.reload - @story3.t.should eq 3 - end - it 'æ¢åã®t3ã4ã«ã·ãããã¦ãã' do - @story6.store - @story4.reload - @story4.t.should eq 4 - end - it 'æ¢åã®t5ã5ã«ã·ãããã¦ãã' do - @story6.store - @story5.reload - @story5.t.should eq 5 - end - it 'æ°è¦ã®t2ãä½æããã¦ãã' do - @story6.store - @story6.reload - @story6.t.should eq 2 - end - it 'ä»ã®ã³ããã¯ã«å½±é¿ããªã' do - @ot = @storyc2.t - @story6.store - @storyc2.reload - @storyc2.t.should eq @ot - end - end - context 'ãã¼ãã«ã«5件(t:0,1,2,3,4)+ä»ã®ã³ããã¯1件ã§3ã1ã«ç§»åããã¨ã' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story4.t - @story4.t = 1 - end - it 'æ¢åã®t0ã«ã¯å¤åããªã' do - @story4.store @ot - @story.reload - @story.t.should eq 0 - end - it 'æ¢åã®t4ã«ã¯å¤åããªã' do - @story4.store @ot - @story5.reload - @story5.t.should eq 4 - end - it 'æ¢åã®t1ã2ã«ã·ãããã¦ãã' do - @story4.store @ot - @story2.reload - @story2.t.should eq 2 - end - it 'æ¢åã®t2ã3ã«ã·ãããã¦ãã' do - @story4.store @ot - @story3.reload - @story3.t.should eq 3 - end - it 'æ¢åã®t3ã1ã«ã·ãããã¦ãã' do - @story4.store @ot - @story4.reload - @story4.t.should eq 1 - end - it 'ä»ã®ã³ããã¯ã«å½±é¿ããªã' do - @story4.store @ot - @storyc2.reload - @storyc2.t.should eq 0 - end - end - context 'ãã¼ãã«ã«5件(t:0,1,2,3,4)+ä»ã®ã³ããã¯1件ã§1ã3ã«ç§»åããã¨ã' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = 3 - end - it 'æ¢åã®t0ã«ã¯å¤åããªã' do - @story2.store @ot - @story.reload - @story.t.should eq 0 - end - it 'æ¢åã®t4ã«ã¯å¤åããªã' do - @story2.store @ot - @story5.reload - @story5.t.should eq 4 - end - it 'æ¢åã®t1ã3ã«ã·ãããã¦ãã' do - @story2.store @ot - @story2.reload - @story2.t.should eq 3 - end - it 'æ¢åã®t2ã1ã«ã·ãããã¦ãã' do - @story2.store @ot - @story3.reload - @story3.t.should eq 1 - end - it 'æ¢åã®t3ã2ã«ã·ãããã¦ãã' do - @story2.store @ot - @story4.reload - @story4.t.should eq 2 - end - it 'ä»ã®ã³ããã¯ã«å½±é¿ããªã' do - @story2.store @ot - @storyc2.reload - @storyc2.t.should eq 0 - end - end - #ãã¼ã«ããã¯ãã¹ããå ¥ãæ¿ããç´æ¥DBããããã®ã§ããã¹ã¦ã®ã±ã¼ã¹ã§ç¢ºå®ã«ãã¼ã«ããã¯ã確èªãã - context 'ãã¼ãã«ã«5件(t:0,1,2,3,4)+ä»ã®ã³ããã¯1件ã§2ã«æ¿å ¥ãããä¿åã«å¤±æããã¨ã' do - before do - Story.any_instance.stub(:save).with(any_args).and_return(false) - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it 'æ¢åã®tã«å¤åããªã' do - @story6.store - @story.reload - @story.t.should eq 0 - @story2.reload - @story2.t.should eq 1 - @story3.reload - @story3.t.should eq 2 - @story4.reload - @story4.t.should eq 3 - @story5.reload - @story5.t.should eq 4 - @storyc2.reload - @storyc2.t.should eq 0 - end - it 'falseãè¿ã' do - r = @story6.store - r.should be_false - end - end - context 'ãã¼ãã«ã«5件(t:0,1,2,3,4)+ä»ã®ã³ããã¯1件ã§3ã1ã«ç§»åãããã·ãªã¢ã«ãã§ãã¯ã«å¤±æããã¨ã' do - before do - Story.stub(:validate_t).with(any_args).and_return(false) - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story4.t - @story4.t = 1 - end - it 'æ¢åã®tã«å¤åããªã' do - @story4.store @ot - @story.reload - @story.t.should eq 0 - @story2.reload - @story2.t.should eq 1 - @story3.reload - @story3.t.should eq 2 - @story4.reload - @story4.t.should eq 3 - @story5.reload - @story5.t.should eq 4 - @storyc2.reload - @storyc2.t.should eq 0 - end - it 'falseãè¿ã' do - r = @story4.store @ot - r.should be_false - end - it 'tã«ã¨ã©ã¼ã¡ãã»ã¼ã¸ãå ¥ã£ã¦ãã' do - @story4.store @ot - @story4.errors[:t].should_not be_empty - @story4.valid?.should be_true - end - end - context 'ç·¨éä¸å¯ã ã£ãã¨ã' do - before do - @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.any_instance.stub(:allow?).and_return(false) - end - it '403Forbiddenä¾å¤ãè¿ã' do - lambda{ - @story.store - }.should raise_error(ActiveRecord::Forbidden) - end - end - end - describe 'åãè©°ãå¦çã¤ãåé¤ã«æ¼ãã¦' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'ã¤ã¤ããªãçµããã¨ã' do - it 'åé¤ããã' do - lambda{ - @story.destroy_and_shorten - }.should change(Story, :count ).by(-1) - end - it 'Trueãè¿ã' do - r = @story.destroy_and_shorten - r.should be_true - end - end - context 'åé¤ã«å¤±æããã¨ã' do - before do - Story.any_instance.stub(:destroy).and_return(false) - end - it 'ãã¼ã«ããã¯ããã' do - lambda{ - @story.destroy_and_shorten - }.should_not change(Story, :count ) - end - it 'Falseãè¿ã' do - r = @story.destroy_and_shorten - r.should be_false - end - end - #é£æºãã¹ããåãè©°ããç´æ¥DBãããã - context '2件ã§å é ãåé¤ããã¨ã' do - before do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it 'è¡ãåé¤ããã' do - lambda{ - @story.destroy_and_shorten - }.should change(Story, :count ).by(-1) - end - it 'å é ã¯åé¤ããã' do - @story.destroy_and_shorten - lambda{ - Story.find @story.id - }.should raise_error(ActiveRecord::RecordNotFound) - end - it '2件ç®ã¯åã«è©°ãããã' do - @story.destroy_and_shorten - @story2.reload - @story2.t.should eq 0 - end - end - context '3件ã§å é ãåé¤ããã¨ã' do - before do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it 'è¡ãåé¤ããã' do - lambda{ - @story.destroy_and_shorten - }.should change(Story, :count ).by(-1) - end - it 'å é ã¯åé¤ããã' do - @story.destroy_and_shorten - lambda{ - Story.find @story.id - }.should raise_error(ActiveRecord::RecordNotFound) - end - it '2件ç®ã¯åã«è©°ãããã' do - @story.destroy_and_shorten - @story2.reload - @story2.t.should eq 0 - end - it '3件ç®ã¯åã«è©°ãããã' do - @story.destroy_and_shorten - @story3.reload - @story3.t.should eq 1 - end - end - context '5件ã§3件ç®ãåé¤ããã¨ã' do - before do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it 'è¡ãåé¤ããã' do - lambda{ - @story3.destroy_and_shorten - }.should change(Story, :count ).by(-1) - end - it '1件ç®ã¯å¤åããªã' do - @story3.destroy_and_shorten - @story.reload - @story.t.should eq 0 - end - it '2件ç®ã¯å¤åããªã' do - @story3.destroy_and_shorten - @story2.reload - @story2.t.should eq 1 - end - it '3件ç®ã¯åé¤ããã' do - @story3.destroy_and_shorten - lambda{ - Story.find @story3.id - }.should raise_error(ActiveRecord::RecordNotFound) - end - it '4件ç®ã¯åã«è©°ãããã' do - @story3.destroy_and_shorten - @story4.reload - @story4.t.should eq 2 - end - it '5件ç®ã¯åã«è©°ãããã' do - @story3.destroy_and_shorten - @story5.reload - @story5.t.should eq 3 - end - end - #ãã¼ã«ããã¯ãã¹ããåãè©°ããç´æ¥DBããããã®ã§ããã¹ã¦ã®ã±ã¼ã¹ã§ç¢ºå®ã«ãã¼ã«ããã¯ã確èªãã - end -end -- 2.11.0 |