SHIMADA Koji
null+****@clear*****
Tue Sep 11 16:47:44 JST 2012
SHIMADA Koji 2012-09-11 16:47:44 +0900 (Tue, 11 Sep 2012) New Revision: 1c9ecc33d80341315f90e0c55db1d1477bf7d566 https://github.com/logaling/logaling-server/commit/1c9ecc33d80341315f90e0c55db1d1477bf7d566 Log: Add scenario about creating user glossary Added files: features/manage_user_glossaries.feature features/step_definitions/signup_steps.rb features/step_definitions/user_glossary_steps.rb spec/fabricators/user_fabricator.rb Modified files: app/controllers/user_glossaries_controller.rb app/views/layouts/application.html.haml app/views/user_glossaries/_form.html.haml config/routes.rb features/support/env.rb Modified: app/controllers/user_glossaries_controller.rb (+1 -1) =================================================================== --- app/controllers/user_glossaries_controller.rb 2012-09-11 15:57:37 +0900 (f11128c) +++ app/controllers/user_glossaries_controller.rb 2012-09-11 16:47:44 +0900 (2762b79) @@ -26,7 +26,7 @@ class UserGlossariesController < ApplicationController @user_glossary.save! respond_to do |format| - format.html { render action: "show", notice: 'User glossary was successfully created.' } + format.html { redirect_to user_glossary_path(current_user, @user_glossary), notice: 'User glossary was successfully created.' } format.json { render json: @user_glossary, status: :created, location: @user_glossary } end rescue => e Modified: app/views/layouts/application.html.haml (+2 -1) =================================================================== --- app/views/layouts/application.html.haml 2012-09-11 15:57:37 +0900 (6050757) +++ app/views/layouts/application.html.haml 2012-09-11 16:47:44 +0900 (cd0931d) @@ -35,7 +35,8 @@ %li= link_to "Sign in with #{provider.capitalize}", "/auth/#{provider}" .container - + - [:notice, :alert, :error].map {|k| flash[k] }.reject {|msg| msg.blank? }.each do |msg| + %p= msg .content .row .span12 Modified: app/views/user_glossaries/_form.html.haml (+3 -3) =================================================================== --- app/views/user_glossaries/_form.html.haml 2012-09-11 15:57:37 +0900 (b3d6f02) +++ app/views/user_glossaries/_form.html.haml 2012-09-11 16:47:44 +0900 (d19d4ac) @@ -7,11 +7,11 @@ %li= msg .well - %p Glossary name: + = f.label :name, "Glossary name:" = f.text_field :name - %p Source language: + = f.label :source_language, "Source language:" = f.text_field :source_language - %p Target language: + = f.label :target_language, "Target language:" = f.text_field :target_language .actions Modified: config/routes.rb (+6 -4) =================================================================== --- config/routes.rb 2012-09-11 15:57:37 +0900 (d0617ce) +++ config/routes.rb 2012-09-11 16:47:44 +0900 (99c3f8f) @@ -12,10 +12,12 @@ LogalingServer::Application.routes.draw do :only => :show end - resources :user_glossaries, - :path => 'users/:user_id/glossaries', - :constraints => {:id => %r{[^-]+-[^-]+}}, - :only => [:new, :create, :show] + resources :users, :only => [] do + resources :user_glossaries, + :path => 'glossaries', + :only => [:new, :create, :show], + :as => :glossaries + end match '/auth/:provider/callback', to: 'sessions#create' match '/auth/failure', to: 'sessions#failure' Added: features/manage_user_glossaries.feature (+19 -0) 100644 =================================================================== --- /dev/null +++ features/manage_user_glossaries.feature 2012-09-11 16:47:44 +0900 (6e076f2) @@ -0,0 +1,19 @@ +#language: ja +フィーチャ: 個人用の用語集を作成できる + コマンドラインに不慣れな翻訳者として + Web から用語集の作成・編集ができると嬉しい + なぜなら logaling-command は使えないけど + 対訳用語集はあると作業が捗りそうだからだ + + 背景: + 前提 ユーザ"kinoko"でログインしている + かつ ダッシュボードを表示している + + シナリオ: 対訳用語集を新規作成できる + 前提 "Create user glossary"リンクをクリックする + もし "Glossary name:"に"my_glossary"と入力する + かつ "Source language:"に"en"と入力する + かつ "Target language:"に"ja"と入力する + かつ "Save"をクリックする + ならば "User glossary was successfully created."と表示されていること + Added: features/step_definitions/signup_steps.rb (+12 -0) 100644 =================================================================== --- /dev/null +++ features/step_definitions/signup_steps.rb 2012-09-11 16:47:44 +0900 (8b7c60d) @@ -0,0 +1,12 @@ +#coding: utf-8 + +前提 /^ユーザ"([^"]*)"でログインしている$/ do |name| + page.reset_session! + OmniAuth.config.add_mock(:github, uid: SecureRandom.hex(8), info: {name: name}) + user = Fabricate(:user, name: name, provider: 'github') + visit '/auth/github' +end + +前提 /^ダッシュボードを表示している$/ do + visit '/dashboard' +end Added: features/step_definitions/user_glossary_steps.rb (+13 -0) 100644 =================================================================== --- /dev/null +++ features/step_definitions/user_glossary_steps.rb 2012-09-11 16:47:44 +0900 (e7fd2d4) @@ -0,0 +1,13 @@ +#coding: utf-8 + +前提 /^"([^"]*)"リンクをクリックする$/ do |arg| + click_on arg +end + +もし /^"([^"]*)"に"([^"]*)"と入力する$/ do |name, val| + fill_in name, with: val +end + +もし /^"([^"]*)"をクリックする$/ do |arg| + step %Q{"#{arg}"リンクをクリックする} +end Modified: features/support/env.rb (+2 -1) =================================================================== --- features/support/env.rb 2012-09-11 15:57:37 +0900 (dc25ff4) +++ features/support/env.rb 2012-09-11 16:47:44 +0900 (8ac63ff) @@ -47,7 +47,8 @@ end # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do # DatabaseCleaner.strategy = :transaction # end -# +OmniAuth.config.test_mode = true + Before do LogalingServer.flush_data_directory! end Added: spec/fabricators/user_fabricator.rb (+5 -0) 100644 =================================================================== --- /dev/null +++ spec/fabricators/user_fabricator.rb 2012-09-11 16:47:44 +0900 (b0006a4) @@ -0,0 +1,5 @@ +Fabricator(:user) do + name { Faker::Internet.user_name } + uid { rand(2**32).to_s } + provider 'github' +end -------------- next part -------------- An HTML attachment was scrubbed... ダウンロード