From 9cabe04368024f44881e4269a008156f1629ab86 Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 27 Sep 2012 23:23:11 +0300 Subject: [PATCH] tests for: Profile -> History --- app/models/event.rb | 1 + features/profile/profile.feature | 5 +++++ features/steps/profile/profile.rb | 8 ++++++++ features/steps/shared/authentication.rb | 4 ++++ spec/factories.rb | 6 ++++++ 5 files changed, 24 insertions(+) diff --git a/app/models/event.rb b/app/models/event.rb index 43131ad6..535e778d 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -20,6 +20,7 @@ class Event < ActiveRecord::Base delegate :title, to: :issue, prefix: true, allow_nil: true delegate :title, to: :merge_request, prefix: true, allow_nil: true + belongs_to :author, class_name: "User" belongs_to :project belongs_to :target, polymorphic: true diff --git a/features/profile/profile.feature b/features/profile/profile.feature index 134cabb5..d07a6db1 100644 --- a/features/profile/profile.feature +++ b/features/profile/profile.feature @@ -20,3 +20,8 @@ Feature: Profile Given I visit profile account page Then I reset my token And I should see new token + + Scenario: I visit history tab + Given I have activity + When I visit profile history page + Then I should see my activity diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb index d3261a16..605936ba 100644 --- a/features/steps/profile/profile.rb +++ b/features/steps/profile/profile.rb @@ -41,4 +41,12 @@ class Profile < Spinach::FeatureSteps find("#token").value.should_not == @old_token find("#token").value.should == @user.reload.private_token end + + Given 'I have activity' do + Factory :closed_issue_event, author: current_user + end + + Then 'I should see my activity' do + page.should have_content "#{current_user.name} closed issue" + end end diff --git a/features/steps/shared/authentication.rb b/features/steps/shared/authentication.rb index 2add9161..8c501bbc 100644 --- a/features/steps/shared/authentication.rb +++ b/features/steps/shared/authentication.rb @@ -11,4 +11,8 @@ module SharedAuthentication Given 'I sign in as an admin' do login_as :admin end + + def current_user + @user || User.first + end end diff --git a/spec/factories.rb b/spec/factories.rb index e11e6d07..760465aa 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -78,6 +78,12 @@ FactoryGirl.define do end factory :event do + factory :closed_issue_event do + project + action Event::Closed + target factory: :closed_issue + author factory: :user + end end factory :key do