Commit 9cabe04368024f44881e4269a008156f1629ab86

Authored by randx
1 parent 68f4b597

tests for: Profile -> History

app/models/event.rb
@@ -20,6 +20,7 @@ class Event < ActiveRecord::Base @@ -20,6 +20,7 @@ class Event < ActiveRecord::Base
20 delegate :title, to: :issue, prefix: true, allow_nil: true 20 delegate :title, to: :issue, prefix: true, allow_nil: true
21 delegate :title, to: :merge_request, prefix: true, allow_nil: true 21 delegate :title, to: :merge_request, prefix: true, allow_nil: true
22 22
  23 + belongs_to :author, class_name: "User"
23 belongs_to :project 24 belongs_to :project
24 belongs_to :target, polymorphic: true 25 belongs_to :target, polymorphic: true
25 26
features/profile/profile.feature
@@ -20,3 +20,8 @@ Feature: Profile @@ -20,3 +20,8 @@ Feature: Profile
20 Given I visit profile account page 20 Given I visit profile account page
21 Then I reset my token 21 Then I reset my token
22 And I should see new token 22 And I should see new token
  23 +
  24 + Scenario: I visit history tab
  25 + Given I have activity
  26 + When I visit profile history page
  27 + Then I should see my activity
features/steps/profile/profile.rb
@@ -41,4 +41,12 @@ class Profile < Spinach::FeatureSteps @@ -41,4 +41,12 @@ class Profile < Spinach::FeatureSteps
41 find("#token").value.should_not == @old_token 41 find("#token").value.should_not == @old_token
42 find("#token").value.should == @user.reload.private_token 42 find("#token").value.should == @user.reload.private_token
43 end 43 end
  44 +
  45 + Given 'I have activity' do
  46 + Factory :closed_issue_event, author: current_user
  47 + end
  48 +
  49 + Then 'I should see my activity' do
  50 + page.should have_content "#{current_user.name} closed issue"
  51 + end
44 end 52 end
features/steps/shared/authentication.rb
@@ -11,4 +11,8 @@ module SharedAuthentication @@ -11,4 +11,8 @@ module SharedAuthentication
11 Given 'I sign in as an admin' do 11 Given 'I sign in as an admin' do
12 login_as :admin 12 login_as :admin
13 end 13 end
  14 +
  15 + def current_user
  16 + @user || User.first
  17 + end
14 end 18 end
spec/factories.rb
@@ -78,6 +78,12 @@ FactoryGirl.define do @@ -78,6 +78,12 @@ FactoryGirl.define do
78 end 78 end
79 79
80 factory :event do 80 factory :event do
  81 + factory :closed_issue_event do
  82 + project
  83 + action Event::Closed
  84 + target factory: :closed_issue
  85 + author factory: :user
  86 + end
81 end 87 end
82 88
83 factory :key do 89 factory :key do