SHIMADA Koji
null+****@clear*****
Thu Sep 27 12:49:51 JST 2012
SHIMADA Koji 2012-09-27 12:49:51 +0900 (Thu, 27 Sep 2012) New Revision: 6498410efef7c401ce8164bd206deb5680131cac https://github.com/logaling/logaling-server/commit/6498410efef7c401ce8164bd206deb5680131cac Merged a2771e9: Merge pull request #18 from logaling/fix-specs Log: Fix specs Modified files: app/controllers/search_controller.rb app/controllers/terms_controller.rb app/controllers/user_glossaries_controller.rb app/models/user_glossary.rb features/manage_user_glossaries.feature features/step_definitions/project_steps.rb features/step_definitions/user_glossary_steps.rb Renamed files: app/models/glossary_entry.rb (from app/models/term.rb) Modified: app/controllers/search_controller.rb (+1 -1) =================================================================== --- app/controllers/search_controller.rb 2012-09-27 10:49:20 +0900 (b42aab7) +++ app/controllers/search_controller.rb 2012-09-27 12:49:51 +0900 (1329101) @@ -4,7 +4,7 @@ class SearchController < ApplicationController priority_glossary = signed_in? ? current_user.priority_glossary : nil @terms = LogalingServer.repository.lookup(@query, priority_glossary).map do |t| - Term.new do |o| + GlossaryEntry.new do |o| o.extend AdditionalInformationAsSearchResults o.attributes = t end Modified: app/controllers/terms_controller.rb (+6 -6) =================================================================== --- app/controllers/terms_controller.rb 2012-09-27 10:49:20 +0900 (e897408) +++ app/controllers/terms_controller.rb 2012-09-27 12:49:51 +0900 (bfbe0fd) @@ -3,11 +3,11 @@ class TermsController < ApplicationController before_filter :set_user_glossary def new - @term = Term.new + @term = GlossaryEntry.new end def create - @term = Term.new(params[:term]) + @term = GlossaryEntry.new(params[:term]) @user_glossary.add!(@term) redirect_to user_glossary_path(current_user, @user_glossary), notice: 'Term was successfully added.' @@ -16,12 +16,12 @@ class TermsController < ApplicationController end def edit - @term = Term.load(params[:id], @user_glossary) + @term = GlossaryEntry.load(params[:id], @user_glossary) end def update - @term = Term.load(params[:id], @user_glossary) - new_term = Term.new(params[:term]) + @term = GlossaryEntry.load(params[:id], @user_glossary) + new_term = GlossaryEntry.new(params[:term]) @user_glossary.update(@term, new_term) redirect_to user_glossary_path(current_user, @user_glossary), notice: 'Term was successfully updated.' @@ -30,7 +30,7 @@ class TermsController < ApplicationController end def destroy - @term = Term.load(params[:id], @user_glossary) + @term = GlossaryEntry.load(params[:id], @user_glossary) @user_glossary.delete(@term) redirect_to user_glossary_path(current_user, @user_glossary), notice: 'Term was successfully destroyed.' Modified: app/controllers/user_glossaries_controller.rb (+1 -1) =================================================================== --- app/controllers/user_glossaries_controller.rb 2012-09-27 10:49:20 +0900 (a03aeec) +++ app/controllers/user_glossaries_controller.rb 2012-09-27 12:49:51 +0900 (ce2ea52) @@ -5,7 +5,7 @@ class UserGlossariesController < ApplicationController # GET /user_glossaries/1 def show - @term = Term.new + @term = GlossaryEntry.new @user_glossary = UserGlossary.find(params[:id]) rescue ActiveRecord::RecordNotFound render :file => 'public/404.html', :status => 404, :layout => false Renamed: app/models/glossary_entry.rb (+6 -1) 75% =================================================================== --- app/models/term.rb 2012-09-27 10:49:20 +0900 (5e2b402) +++ app/models/glossary_entry.rb 2012-09-27 12:49:51 +0900 (bd5522b) @@ -1,5 +1,10 @@ #coding: utf-8 -class Term + +# Although we would like to set the name of this to Term, +# it is difficult owing to the following: +# http://stackoverflow.com/questions/1736747/how-to-resolve-rails-model-namespace-collision +# Therefore, it is provisionally considered as the following names. +class GlossaryEntry class << self def find(id) source_term, target_term = id_to_source_term_and_target_term(id) Modified: app/models/user_glossary.rb (+2 -1) =================================================================== --- app/models/user_glossary.rb 2012-09-27 10:49:20 +0900 (367433c) +++ app/models/user_glossary.rb 2012-09-27 12:49:51 +0900 (5a8ce0c) @@ -83,7 +83,7 @@ class UserGlossary < ActiveRecord::Base def terms(annotation=nil) glossary = find_glossary raise Logaling::GlossaryNotFound unless glossary - terms = glossary.terms(annotation).map { |term_attrs| Term.new(term_attrs) } + terms = glossary.terms(annotation).map { |term_attrs| GlossaryEntry.new(term_attrs) } end private @@ -93,5 +93,6 @@ class UserGlossary < ActiveRecord::Base def create_personal_project! LogalingServer.repository.create_personal_project(glossary_name, source_language, target_language) + LogalingServer.repository.index end end Modified: features/manage_user_glossaries.feature (+6 -7) =================================================================== --- features/manage_user_glossaries.feature 2012-09-27 10:49:20 +0900 (6e076f2) +++ features/manage_user_glossaries.feature 2012-09-27 12:49:51 +0900 (51194b5) @@ -10,10 +10,9 @@ かつ ダッシュボードを表示している シナリオ: 対訳用語集を新規作成できる - 前提 "Create user glossary"リンクをクリックする - もし "Glossary name:"に"my_glossary"と入力する - かつ "Source language:"に"en"と入力する - かつ "Target language:"に"ja"と入力する - かつ "Save"をクリックする - ならば "User glossary was successfully created."と表示されていること - + 前提 "新しい用語集をつくる"リンクをクリックする + もし "名前"に"my_glossary"と入力する + かつ "元言語"に"en"と入力する + かつ "翻訳言語"に"ja"と入力する + かつ "登録する"をクリックする + ならば 対訳用語集"my_glossary en ja"が作成済みであること Modified: features/step_definitions/project_steps.rb (+2 -2) =================================================================== --- features/step_definitions/project_steps.rb 2012-09-27 10:49:20 +0900 (d31b519) +++ features/step_definitions/project_steps.rb 2012-09-27 12:49:51 +0900 (a142b08) @@ -15,12 +15,12 @@ end もし /^"([^"]*)"ユーザの"([^"]*)"プロジェクトを登録する$/ do |owner, project| fill_in 'github_project_owner', with: owner fill_in 'github_project_name', with: project - click_on 'Save' + click_on '登録する' end もし /^"([^"]*)"と検索する$/ do |query| fill_in 'query', with: query - click_on 'Search' + click_on '検索' end ならば /^"([^"]*)"ユーザの"([^"]*)"プロジェクトが登録されていないこと$/ do |owner, project| Modified: features/step_definitions/user_glossary_steps.rb (+5 -0) =================================================================== --- features/step_definitions/user_glossary_steps.rb 2012-09-27 10:49:20 +0900 (e7fd2d4) +++ features/step_definitions/user_glossary_steps.rb 2012-09-27 12:49:51 +0900 (a2ff0a1) @@ -11,3 +11,8 @@ end もし /^"([^"]*)"をクリックする$/ do |arg| step %Q{"#{arg}"リンクをクリックする} end + +ならば /^対訳用語集"([^"]*)"が作成済みであること$/ do |glossary_name| + page.should have_content(glossary_name) +end + -------------- next part -------------- An HTML attachment was scrubbed... Download