From 14a8ac3eead9b30c975a6a482e44cadaa3768698 Mon Sep 17 00:00:00 2001 From: Junv Date: Thu, 15 Nov 2012 16:51:28 +0800 Subject: [PATCH 1/8] fix quit team function,and remove the team show page will always show yourselef"s infomation,in no matter past,current,future --- Gemfile.lock | 2 +- app/controllers/teams_controller.rb | 17 +++++++++-------- app/helpers/teams_helper.rb | 1 - app/models/membership.rb | 8 ++++++-- app/models/person.rb | 9 +++++++++ spec/controllers/teams_controller_spec.rb | 7 +++++-- spec/models/person_spec.rb | 14 ++++++++++++++ 7 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c6c34f6..6256dc4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,5 @@ GEM - remote: http://ruby.taobao.org/ + remote: https://rubygems.org/ specs: actionmailer (3.2.8) actionpack (= 3.2.8) diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index bd5d776..6981bc9 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -39,13 +39,6 @@ class TeamsController < ApplicationController end end - def join - with_team do |team| - current_person.teams << team - redirect_to "/teams/#{team.slug}" - end - end - def show with_team { render :show } end @@ -62,9 +55,17 @@ class TeamsController < ApplicationController render :quiz end end + + def join + with_team do |team| + current_person.join team + redirect_to "/teams/#{team.slug}" + end + end + def quit with_team do |team| - current_person.teams.delete(team) + current_person.leave team end redirect_to "/teams" end diff --git a/app/helpers/teams_helper.rb b/app/helpers/teams_helper.rb index 42ff0aa..50e9c11 100644 --- a/app/helpers/teams_helper.rb +++ b/app/helpers/teams_helper.rb @@ -1,6 +1,5 @@ module TeamsHelper def membership_partial membership - return 'my_membership' if membership.person == @current_person membership.pending? ? 'pending_membership' : 'approved_membership' end end \ No newline at end of file diff --git a/app/models/membership.rb b/app/models/membership.rb index 0c9c20f..cdaca84 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -12,7 +12,7 @@ class Membership < ActiveRecord::Base delegate :track, :photo, :gravatar_url, to: :person, prefix: true delegate :name, :slug, :description, to: :team, prefix: true - scope :approved, where('pending_approval_token is null') + scope :approved, where('pending_approval_token is null and ended is null') def self.create_pending_membership inviter, team, person membership = Membership.create team: team, @@ -23,7 +23,7 @@ class Membership < ActiveRecord::Base def status return 'future hidden' if started and started > Date.today - return 'past hidden' if ended and Date.today > ended + return 'past hidden' if ended and Date.today >= ended return 'silent hidden' if hidden 'current' end @@ -36,6 +36,10 @@ class Membership < ActiveRecord::Base update_attributes pending_approval_token: nil end + def leave + update_attributes ended: Date.today + end + def self.api_attributes_for user user.memberships.includes('team').map do |m| attr = m.attributes.except(*%w{id person_id team_id pending_approval_token}) diff --git a/app/models/person.rb b/app/models/person.rb index 46b6d21..44c4a4a 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -76,4 +76,13 @@ class Person < ActiveRecord::Base def email_domain email.split('@').last end + + def leave (team) + Membership.where(team_id: team.id,person_id: id).first.leave + end + + def join(team) + teams << team + end + end \ No newline at end of file diff --git a/spec/controllers/teams_controller_spec.rb b/spec/controllers/teams_controller_spec.rb index 8bf2b2c..4257d4e 100644 --- a/spec/controllers/teams_controller_spec.rb +++ b/spec/controllers/teams_controller_spec.rb @@ -72,12 +72,15 @@ describe TeamsController do end end describe :quit do - it 'ensure when people quit a team then destroy a membership' do + it 'ensure when people quit a team then set the relationship ended,and the team should removed from approved team' do team = Team.create(name: 'LSP', slug: 'lsp') + post :join, :slug => team.slug lambda do - post :join, :slug => team.slug post :quit, :slug => team.slug end.should change(Membership,:count).by(0) + membership = Membership.find(:last) + membership.status.should == 'past hidden' + @person.approved_teams.include?(team).should_not == true end end end \ No newline at end of file diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 18b483d..b7f86c1 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -67,4 +67,18 @@ describe Person do person.viewable_teams.should_not be_include(joined_team) end end + + describe 'person team membership' do + + it 'leave team correctly' do + team = Team.create(name: 'LSP', slug: 'lsp') + person = Person.create_for_email("user@email.com") + person.teams << team + + person.leave(team) + membership = Membership.find(:last) + membership.status.should == 'past hidden' + end + + end end \ No newline at end of file From 99bccd0477bf388210653971250e1fc604cd797b Mon Sep 17 00:00:00 2001 From: szpyxlwoni Date: Thu, 15 Nov 2012 17:05:23 +0800 Subject: [PATCH 2/8] modify cucumber for test main process --- Gemfile.lock | 2 +- app/assets/javascripts/test.js.coffee | 3 +++ app/assets/stylesheets/test.css.scss | 3 +++ app/controllers/test_controller.rb | 10 ++++++++++ app/helpers/test_helper.rb | 2 ++ app/views/home/index.html.slim | 1 + app/views/test/test_login.html.slim | 0 config/routes.rb | 2 ++ features/main_process.feature | 3 ++- features/step_definitions/main_process.rb | 8 ++++++-- lib/google_api_ext.rb | 2 +- spec/controllers/test_controller_spec.rb | 12 ++++++++++++ spec/helpers/test_helper_spec.rb | 15 +++++++++++++++ spec/lib/google_api_client_spec.rb | 2 +- 14 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 app/assets/javascripts/test.js.coffee create mode 100644 app/assets/stylesheets/test.css.scss create mode 100644 app/controllers/test_controller.rb create mode 100644 app/helpers/test_helper.rb create mode 100644 app/views/test/test_login.html.slim create mode 100644 spec/controllers/test_controller_spec.rb create mode 100644 spec/helpers/test_helper_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index c6c34f6..6256dc4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,5 @@ GEM - remote: http://ruby.taobao.org/ + remote: https://rubygems.org/ specs: actionmailer (3.2.8) actionpack (= 3.2.8) diff --git a/app/assets/javascripts/test.js.coffee b/app/assets/javascripts/test.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/test.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/test.css.scss b/app/assets/stylesheets/test.css.scss new file mode 100644 index 0000000..97f8988 --- /dev/null +++ b/app/assets/stylesheets/test.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the test controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb new file mode 100644 index 0000000..f3e8af2 --- /dev/null +++ b/app/controllers/test_controller.rb @@ -0,0 +1,10 @@ +class TestController < ApplicationController + skip_before_filter :require_login, :only => :test_login + + def test_login + if Rails.env.test? + session[:email] = "test@gmail.com" + redirect_to "/teams" + end + end +end diff --git a/app/helpers/test_helper.rb b/app/helpers/test_helper.rb new file mode 100644 index 0000000..09b6d50 --- /dev/null +++ b/app/helpers/test_helper.rb @@ -0,0 +1,2 @@ +module TestHelper +end diff --git a/app/views/home/index.html.slim b/app/views/home/index.html.slim index f67b355..4097eb2 100644 --- a/app/views/home/index.html.slim +++ b/app/views/home/index.html.slim @@ -27,6 +27,7 @@ a.btn.btn-primary href="/home/verify_g" Google span.separator or a.btn.btn-primary.persona#authenticate Mozilla Persona + btn#test_login style='visibility:hidden' href='/test_login' TestLogin footer ul li diff --git a/app/views/test/test_login.html.slim b/app/views/test/test_login.html.slim new file mode 100644 index 0000000..e69de29 diff --git a/config/routes.rb b/config/routes.rb index 8efc5a9..9e88864 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,5 +44,7 @@ Ocelots::Application.routes.draw do get 'antechamber/:slug' => 'antechamber#index' post 'antechamber/:slug' => 'antechamber#create' + get 'test_login' => 'test#test_login' + root to: 'home#index' end \ No newline at end of file diff --git a/features/main_process.feature b/features/main_process.feature index 733bb5b..6ac9573 100644 --- a/features/main_process.feature +++ b/features/main_process.feature @@ -6,4 +6,5 @@ Feature: Main process of Ocelots Scenario: Go to home page Given I am not signed in When I go to home page - Then I should see sign in buttons + Then I should click login link + Then I see list of team diff --git a/features/step_definitions/main_process.rb b/features/step_definitions/main_process.rb index fb02f1b..ddabb96 100644 --- a/features/step_definitions/main_process.rb +++ b/features/step_definitions/main_process.rb @@ -6,6 +6,10 @@ When /^I go to home page$/ do visit '/' end -Then /^I should see sign in buttons$/ do - # TODO: assertion here +Then /^I should click login link$/ do + page.execute_script("$('#test_login').click();") +end + +Then /^I see list of team$/ do + end diff --git a/lib/google_api_ext.rb b/lib/google_api_ext.rb index aca9feb..5a1ec39 100644 --- a/lib/google_api_ext.rb +++ b/lib/google_api_ext.rb @@ -19,7 +19,7 @@ Google::APIClient.class_eval do origin: 'iocelots.com', client_id: '1030433741080.apps.googleusercontent.com', client_secret: 'RAQdt17GKweBtQzOCq6Dp965', - redirect_uri: 'http://www.iocelots.com/home/verify_g_callback' + redirect_uri: 'http://iocelots.com/home/verify_g_callback' } ] client_configuration = configurations.find{|conf| origin.include?(conf[:origin])} diff --git a/spec/controllers/test_controller_spec.rb b/spec/controllers/test_controller_spec.rb new file mode 100644 index 0000000..328d988 --- /dev/null +++ b/spec/controllers/test_controller_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe TestController do + + describe :test_login do + it 'ensure person login with test email if Rails environment is test' do + get :test_login + session[:email] == 'test@gmail.com' + assert_redirected_to '/teams' + end + end +end diff --git a/spec/helpers/test_helper_spec.rb b/spec/helpers/test_helper_spec.rb new file mode 100644 index 0000000..0785ef5 --- /dev/null +++ b/spec/helpers/test_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the TestHelper. For example: +# +# describe TestHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe TestHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/lib/google_api_client_spec.rb b/spec/lib/google_api_client_spec.rb index 2194452..e18e621 100644 --- a/spec/lib/google_api_client_spec.rb +++ b/spec/lib/google_api_client_spec.rb @@ -14,7 +14,7 @@ describe Google::APIClient do it 'builds google api client for production' do client = Google::APIClient.build('iocelots.com') - client.authorization.redirect_uri.to_s.should == 'http://www.iocelots.com/home/verify_g_callback' + client.authorization.redirect_uri.to_s.should == 'http://iocelots.com/home/verify_g_callback' end end end \ No newline at end of file From 7c6760a8b6493617b112e4108e6db8c834e1197c Mon Sep 17 00:00:00 2001 From: szpyxlwoni Date: Thu, 15 Nov 2012 17:45:38 +0800 Subject: [PATCH 3/8] cancel some modify to make test pass --- app/controllers/test_controller.rb | 6 +++++- app/views/home/index.html.slim | 2 +- features/step_definitions/main_process.rb | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index f3e8af2..324c41d 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -3,8 +3,12 @@ class TestController < ApplicationController def test_login if Rails.env.test? - session[:email] = "test@gmail.com" + @current_person = test_sign_in redirect_to "/teams" end end + + def test_sign_in + Person.create!(email: "test@gmail.com", full_name: 'Test Person', account: 'test_account') + end end diff --git a/app/views/home/index.html.slim b/app/views/home/index.html.slim index 4097eb2..82b437d 100644 --- a/app/views/home/index.html.slim +++ b/app/views/home/index.html.slim @@ -27,7 +27,7 @@ a.btn.btn-primary href="/home/verify_g" Google span.separator or a.btn.btn-primary.persona#authenticate Mozilla Persona - btn#test_login style='visibility:hidden' href='/test_login' TestLogin + a#test_login style='visibility:hidden' href='/test_login' TestLogin footer ul li diff --git a/features/step_definitions/main_process.rb b/features/step_definitions/main_process.rb index ddabb96..18a3ca3 100644 --- a/features/step_definitions/main_process.rb +++ b/features/step_definitions/main_process.rb @@ -7,9 +7,9 @@ When /^I go to home page$/ do end Then /^I should click login link$/ do - page.execute_script("$('#test_login').click();") + #page.execute_script("$('#test_login').click();") end Then /^I see list of team$/ do - + #page.should have_content('team') end From e8192df6bea05a991be5dba0487c3ab490880914 Mon Sep 17 00:00:00 2001 From: Junv Date: Thu, 15 Nov 2012 17:49:01 +0800 Subject: [PATCH 4/8] fix some teams will diaply twice --- app/controllers/teams_controller.rb | 2 +- app/views/teams/index.html.slim | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 6981bc9..8459a92 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -4,7 +4,7 @@ class TeamsController < ApplicationController include TeamFilter def index - @memberships = current_person.memberships + @approved_teams = current_person.approved_teams @team = Team.new @organisations = Organisation.find(:all) end diff --git a/app/views/teams/index.html.slim b/app/views/teams/index.html.slim index f001c88..674c03d 100644 --- a/app/views/teams/index.html.slim +++ b/app/views/teams/index.html.slim @@ -27,23 +27,23 @@ div id="add_new" style="display:none;" div.form-actions = form.submit 'Create', class: 'btn' -- @memberships.each do |membership| - a href="/teams/#{membership.team_slug}" +- @approved_teams.each do |team| + a href="/teams/#{team.slug}" div.hero-unit.highlight div.row div.span4 img src="/assets/team.png" div.span4 - h1 = membership.team_name - p = membership.team_description + h1 = team.name + p = team.description div.span1 - - if membership.pending? - = form_tag "/membership/approve" do - input type="hidden" name="id" value="#{membership.id}" - = submit_tag 'Approve', class: 'btn btn-primary btn-block' - = form_tag "/membership/leave" do - input type="hidden" name="id" value="#{membership.id}" - = submit_tag 'Leave', class: 'btn btn-danger btn-block' + /- if membership.pending? + / = form_tag "/membership/approve" do + / input type="hidden" name="id" value="#{membership.id}" + / = submit_tag 'Approve', class: 'btn btn-primary btn-block' + / = form_tag "/membership/leave" do + / input type="hidden" name="id" value="#{membership.id}" + / = submit_tag 'Leave', class: 'btn btn-danger btn-block' div.clearfix - current_person.viewable_teams.each do |team| a href="/teams/#{team.slug}" From a11bc3da4b06ab6cd53f0fa435c0bb1de02cc6fb Mon Sep 17 00:00:00 2001 From: Junv Date: Fri, 16 Nov 2012 09:52:36 +0800 Subject: [PATCH 5/8] back to disply teams which someone has already quit,and fix in some situations the person will display twice --- app/controllers/teams_controller.rb | 2 +- app/models/membership.rb | 3 +++ app/models/person.rb | 7 ++++++- app/views/teams/index.html.slim | 22 +++++++++++----------- spec/controllers/teams_controller_spec.rb | 10 ++++++++++ 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 8459a92..6981bc9 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -4,7 +4,7 @@ class TeamsController < ApplicationController include TeamFilter def index - @approved_teams = current_person.approved_teams + @memberships = current_person.memberships @team = Team.new @organisations = Organisation.find(:all) end diff --git a/app/models/membership.rb b/app/models/membership.rb index cdaca84..9314497 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -34,6 +34,9 @@ class Membership < ActiveRecord::Base def approve update_attributes pending_approval_token: nil + if ended + update_attributes ended: nil + end end def leave diff --git a/app/models/person.rb b/app/models/person.rb index 44c4a4a..7be0ed0 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -82,7 +82,12 @@ class Person < ActiveRecord::Base end def join(team) - teams << team + if Membership.where(team_id: team.id,person_id: id).empty? + teams << team + else + Membership.where(team_id: team.id,person_id: id).first.approve + end + end end \ No newline at end of file diff --git a/app/views/teams/index.html.slim b/app/views/teams/index.html.slim index 674c03d..f001c88 100644 --- a/app/views/teams/index.html.slim +++ b/app/views/teams/index.html.slim @@ -27,23 +27,23 @@ div id="add_new" style="display:none;" div.form-actions = form.submit 'Create', class: 'btn' -- @approved_teams.each do |team| - a href="/teams/#{team.slug}" +- @memberships.each do |membership| + a href="/teams/#{membership.team_slug}" div.hero-unit.highlight div.row div.span4 img src="/assets/team.png" div.span4 - h1 = team.name - p = team.description + h1 = membership.team_name + p = membership.team_description div.span1 - /- if membership.pending? - / = form_tag "/membership/approve" do - / input type="hidden" name="id" value="#{membership.id}" - / = submit_tag 'Approve', class: 'btn btn-primary btn-block' - / = form_tag "/membership/leave" do - / input type="hidden" name="id" value="#{membership.id}" - / = submit_tag 'Leave', class: 'btn btn-danger btn-block' + - if membership.pending? + = form_tag "/membership/approve" do + input type="hidden" name="id" value="#{membership.id}" + = submit_tag 'Approve', class: 'btn btn-primary btn-block' + = form_tag "/membership/leave" do + input type="hidden" name="id" value="#{membership.id}" + = submit_tag 'Leave', class: 'btn btn-danger btn-block' div.clearfix - current_person.viewable_teams.each do |team| a href="/teams/#{team.slug}" diff --git a/spec/controllers/teams_controller_spec.rb b/spec/controllers/teams_controller_spec.rb index 4257d4e..22d2596 100644 --- a/spec/controllers/teams_controller_spec.rb +++ b/spec/controllers/teams_controller_spec.rb @@ -54,6 +54,7 @@ describe TeamsController do end describe :join do + it 'ensure person joins a team and create a membership between person and team' do team = Team.create(name: 'LSP', slug: 'lsp') lambda do @@ -61,6 +62,15 @@ describe TeamsController do end.should change(Membership, :count).by(1) new_membership = Membership.find(:last) new_membership.person.allowed_to_view_team?(new_membership.team).should == true + + end + + it 'ensure when person quit from a team then join it again,and it will not disappear in past situation' do + team = Team.create(name: 'LSP', slug: 'lsp') + post :join ,:slug =>team.slug + post :quit, :slug => team.slug + post :join ,:slug =>team.slug + membership = Membership.find(:last).ended.should == nil end it 'ensure person can not join a team that he is not belong to the organisation of that team' do From 5979c14301a2a4a176ec99d2dc4f213088091cf5 Mon Sep 17 00:00:00 2001 From: Junv Date: Fri, 16 Nov 2012 10:06:04 +0800 Subject: [PATCH 6/8] fix some team will display twice --- app/controllers/teams_controller.rb | 2 +- app/views/teams/index.html.slim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 6981bc9..bbece3f 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -4,7 +4,7 @@ class TeamsController < ApplicationController include TeamFilter def index - @memberships = current_person.memberships + @memberships = current_person.memberships.select{|membership| membership.ended==nil} @team = Team.new @organisations = Organisation.find(:all) end diff --git a/app/views/teams/index.html.slim b/app/views/teams/index.html.slim index f001c88..2ca736c 100644 --- a/app/views/teams/index.html.slim +++ b/app/views/teams/index.html.slim @@ -47,7 +47,7 @@ div id="add_new" style="display:none;" div.clearfix - current_person.viewable_teams.each do |team| a href="/teams/#{team.slug}" - span.badge.badge-info Viewable + span.label.label-info style="float:left" Viewable div.hero-unit.highlight div.row div.span4 From 3768f8257ef5a184c05bd14d0b3e7296c05a4f21 Mon Sep 17 00:00:00 2001 From: szpyxlwoni Date: Fri, 16 Nov 2012 10:08:12 +0800 Subject: [PATCH 7/8] modify cucumber test to make more functional test --- app/controllers/test_controller.rb | 10 +++------- app/views/home/index.html.slim | 1 - features/main_process.feature | 2 ++ features/step_definitions/main_process.rb | 14 ++++++++++++-- spec/controllers/test_controller_spec.rb | 2 +- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index 324c41d..2b7bb73 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -2,13 +2,9 @@ class TestController < ApplicationController skip_before_filter :require_login, :only => :test_login def test_login - if Rails.env.test? - @current_person = test_sign_in - redirect_to "/teams" + if Rails.env.test? || Rails.env.development? + session[:email] = "test@gmail.com" + redirect_to "/" end end - - def test_sign_in - Person.create!(email: "test@gmail.com", full_name: 'Test Person', account: 'test_account') - end end diff --git a/app/views/home/index.html.slim b/app/views/home/index.html.slim index 82b437d..f67b355 100644 --- a/app/views/home/index.html.slim +++ b/app/views/home/index.html.slim @@ -27,7 +27,6 @@ a.btn.btn-primary href="/home/verify_g" Google span.separator or a.btn.btn-primary.persona#authenticate Mozilla Persona - a#test_login style='visibility:hidden' href='/test_login' TestLogin footer ul li diff --git a/features/main_process.feature b/features/main_process.feature index 6ac9573..1f505aa 100644 --- a/features/main_process.feature +++ b/features/main_process.feature @@ -8,3 +8,5 @@ Scenario: Go to home page When I go to home page Then I should click login link Then I see list of team + Then I should add a team + Then I should quit that team diff --git a/features/step_definitions/main_process.rb b/features/step_definitions/main_process.rb index 18a3ca3..782f1c1 100644 --- a/features/step_definitions/main_process.rb +++ b/features/step_definitions/main_process.rb @@ -7,9 +7,19 @@ When /^I go to home page$/ do end Then /^I should click login link$/ do - #page.execute_script("$('#test_login').click();") + page.execute_script("window.location.href='/test_login'") end Then /^I see list of team$/ do - #page.should have_content('team') + page.should have_content('team') +end + +Then /^I should add a team$/ do + click_link('add team') + fill_in 'Team Name', :with => 'Test_team' + fill_in 'URL', :with => 'Test_URL' +end + +Then /^I should quit that team$/ do + pending # express the regexp above with the code you wish you had end diff --git a/spec/controllers/test_controller_spec.rb b/spec/controllers/test_controller_spec.rb index 328d988..622e349 100644 --- a/spec/controllers/test_controller_spec.rb +++ b/spec/controllers/test_controller_spec.rb @@ -6,7 +6,7 @@ describe TestController do it 'ensure person login with test email if Rails environment is test' do get :test_login session[:email] == 'test@gmail.com' - assert_redirected_to '/teams' + assert_redirected_to '/' end end end From 1c3ca05b316fd1e799a7c432538562e7297bbccf Mon Sep 17 00:00:00 2001 From: szpyxlwoni Date: Fri, 16 Nov 2012 10:25:15 +0800 Subject: [PATCH 8/8] modify the test of main process --- features/step_definitions/main_process.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/step_definitions/main_process.rb b/features/step_definitions/main_process.rb index 782f1c1..439cd5b 100644 --- a/features/step_definitions/main_process.rb +++ b/features/step_definitions/main_process.rb @@ -18,8 +18,9 @@ Then /^I should add a team$/ do click_link('add team') fill_in 'Team Name', :with => 'Test_team' fill_in 'URL', :with => 'Test_URL' + click_button 'Create' end Then /^I should quit that team$/ do - pending # express the regexp above with the code you wish you had + click_button 'Quit Team' end