:location => {:controller => params[:controller], :action => params[:action]}
}
@server_result[:location][:id] = params[:id] if params[:id]
- if Admin.count.to_i == 0 or License.count.to_i == 0
- if params[:controller] == 'system' and params[:action] == 'start'
- else
- redirect_to :controller => '/system', :action => 'start'
- end
+ user = if user_signed_in?
+ current_user
else
- user = if user_signed_in?
- current_user
- else
- nil
- end
- author = if user
- user.author
- else
- nil
- end
- artist = if user
- user.artist
- else
- nil
- end
- admin = if admin_signed_in?
- current_admin
- else
- nil
- end
- demand_user = if demand_user_signed_in?
- current_demand_user
- else
- nil
- end
- @operators = Operator.new [user, author, artist, admin, demand_user]
+ nil
+ end
+ author = if user
+ user.author
+ else
+ nil
+ end
+ artist = if user
+ user.artist
+ else
+ nil
+ end
+ admin = if admin_signed_in?
+ current_admin
+ else
+ nil
+ end
+ demand_user = if demand_user_signed_in?
+ current_demand_user
+ else
+ nil
end
+ @operators = Operator.new [user, author, artist, admin, demand_user]
end
def authenticate_reader
describe ScrollsController 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 Manifest.manifest.magic_numbers['run_mode'] == 1
describe '一覧表示に於いて' do
before do
- @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id
- Scroll.stub(:list).and_return([@scroll, @scroll, @scroll])
- sign_in @user
+ #@scroll = FactoryGirl.create :scroll_hello
+ #@author_yas = @scroll.author
+ @author_yas = FactoryGirl.create :yas_with_scrolls
+ @user_yas = @author_yas.user
+ sign_in @user_yas
end
context 'つつがなく終わるとき' do
it 'ステータスコード200 OKを返す' do
end
context 'ユーザ権限がないとき' do
before do
- sign_out @user
+ sign_out @user_yas
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
end
context 'ユーザ権限はないが管理者権限があるとき' do
before do
- sign_out @user
+ sign_out @user_yas
sign_in @admin
end
it 'ステータスコード200 OKを返す' do
end
context 'ユーザだが作家登録していないとき' do
before do
- @author.destroy
+ sign_out @user_yas
+ @user_ghost = FactoryGirl.create :user_ghost
+ sign_in @user_ghost
end
context 'html形式' do
it 'ステータスコード200 OKを返す' do
describe '単体表示に於いて' do
before do
- @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id, :title => 'normal'
+ @scroll = FactoryGirl.create :scroll_hello
+ @author_yas = @scroll.author
+ @user_yas = @author_yas.user
Scroll.stub(:show).and_return(@scroll)
sign_in @user
end
get :show, :id => @scroll.id
response.should be_success
end
- it 'スクロールモデルに単体取得を問い合わせている' do
- Scroll.should_receive(:show).exactly(1)
- get :show
- end
it '@scrollにアレを取得している' do
get :show, :id => @scroll.id
assigns(:scroll).id.should eq(@scroll.id)
get :show, :id => @scroll.id, :format => :json
lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
end
- it 'スクロールモデルにjson単体出力オプションを問い合わせている' do
- Scroll.should_receive(:show_json_opt).exactly(1)
- get :show, :id => @scroll.id, :format => :json
- end
- it 'データがアレになっている' do
- get :show, :id => @scroll.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
+ sign_out @user_yas
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
end
context 'ユーザ権限はないが管理者権限があるとき' do
before do
- sign_out @user
+ sign_out @user_yas
sign_in @admin
end
it 'ステータスコード200 OKを返す' do
end
context 'ユーザだが作家登録していないとき' do
before do
- @author.destroy
+ sign_out @user_yas
+ @user_ghost = FactoryGirl.create :user_ghost
+ sign_in @user_ghost
end
context 'html形式' do
it 'ステータスコード200 OKを返す' do
# -*- encoding: utf-8 -*-\r
FactoryGirl.define do\r
- factory :author001, :class => Author do |i|\r
+ factory :author_yas, :class => Author do |i|\r
i.name 'ペン次郎'\r
- i.user_id 1\r
+ association :user, factory: :user_yas\r
+ ignore do\r
+ scrolls_count 5\r
+ end\r
+ trait :with_scrolls do\r
+ after(:create) do |author, evaluator|\r
+ create_list(:scroll_hello, evaluator.scrolls_count, author: author)\r
+ end\r
+ end\r
+ factory :yas_with_scrolls, traits: [:with_scrolls]\r
end\r
- factory :author002, :class => Author do |i|\r
- i.name 'no name'\r
- i.user_id 2\r
+ factory :author_itojun, :class => Author do |i|\r
+ i.name 'itojun'\r
end\r
factory :author003, :class => Author do |i|\r
i.name 'qqqqqq'\r
- i.user_id 3\r
end\r
factory :author004, :class => Author do |i|\r
i.name 'やる気満々'\r
- i.user_id 4\r
end\r
factory :author005, :class => Author do |i|\r
i.name 'z6'\r
- i.user_id 5\r
end\r
end\r
--- /dev/null
+# -*- encoding: utf-8 -*-\r
+FactoryGirl.define do\r
+ factory :user_yas, :class => User do |i|\r
+ i.email "yas@jmail.com"\r
+ i.password "user0100"\r
+ i.password_confirmation "user0100"\r
+ end\r
+ factory :user_itojun, :class => User do |i|\r
+ i.email "itojun@jmail.com"\r
+ i.password "user0100"\r
+ i.password_confirmation "user0100"\r
+ end\r
+ factory :user_ghost, :class => User do |i|\r
+ i.email "ghost@jmail.com"\r
+ i.password "user0100"\r
+ i.password_confirmation "user0100"\r
+ end\r
+end\r