Commit 5bbf3ccf authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets Committed by randx

Cucumber:

* Profile
* Browse code
* Sceleton for main features
* Wiki
* Commits
parent 6ff99fe9
...@@ -65,6 +65,8 @@ group :development, :test do ...@@ -65,6 +65,8 @@ group :development, :test do
end end
group :test do group :test do
gem 'cucumber-rails', :require => false
gem 'minitest', ">= 2.10"
gem "turn", :require => false gem "turn", :require => false
gem "simplecov", :require => false gem "simplecov", :require => false
gem "shoulda-matchers" gem "shoulda-matchers"
......
...@@ -118,6 +118,15 @@ GEM ...@@ -118,6 +118,15 @@ GEM
coffee-script-source (1.3.3) coffee-script-source (1.3.3)
colored (1.2) colored (1.2)
crack (0.3.1) crack (0.3.1)
cucumber (1.2.1)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.11.0)
json (>= 1.4.6)
cucumber-rails (1.3.0)
capybara (>= 1.1.2)
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
daemons (1.1.8) daemons (1.1.8)
database_cleaner (0.8.0) database_cleaner (0.8.0)
devise (1.5.3) devise (1.5.3)
...@@ -138,6 +147,8 @@ GEM ...@@ -138,6 +147,8 @@ GEM
ffi (1.0.11) ffi (1.0.11)
foreman (0.47.0) foreman (0.47.0)
thor (>= 0.13.6) thor (>= 0.13.6)
gherkin (2.11.0)
json (>= 1.4.6)
git (1.2.5) git (1.2.5)
graphael-rails (0.1.4) graphael-rails (0.1.4)
jeweler jeweler
...@@ -185,6 +196,7 @@ GEM ...@@ -185,6 +196,7 @@ GEM
treetop (~> 1.4.8) treetop (~> 1.4.8)
method_source (0.7.1) method_source (0.7.1)
mime-types (1.18) mime-types (1.18)
minitest (3.1.0)
modernizr (2.5.3) modernizr (2.5.3)
sprockets (~> 2.0) sprockets (~> 2.0)
multi_json (1.3.6) multi_json (1.3.6)
...@@ -348,6 +360,7 @@ DEPENDENCIES ...@@ -348,6 +360,7 @@ DEPENDENCIES
chosen-rails chosen-rails
coffee-rails (= 3.2.2) coffee-rails (= 3.2.2)
colored colored
cucumber-rails
database_cleaner database_cleaner
devise (~> 1.5) devise (~> 1.5)
drapper drapper
...@@ -366,6 +379,7 @@ DEPENDENCIES ...@@ -366,6 +379,7 @@ DEPENDENCIES
launchy launchy
letter_opener letter_opener
linguist (~> 1.0.0)! linguist (~> 1.0.0)!
minitest (>= 2.10)
modernizr (= 2.5.3) modernizr (= 2.5.3)
mysql2 mysql2
omniauth-ldap omniauth-ldap
......
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
development: #
# PRODUCTION
#
production:
adapter: mysql2 adapter: mysql2
encoding: utf8 encoding: utf8
reconnect: false reconnect: false
database: gitlabhq_development database: gitlabhq_production
pool: 5 pool: 5
username: root username: root
password: "secure password" password: "secure password"
# socket: /tmp/mysql.sock # socket: /tmp/mysql.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". #
# Do not set this db to the same as development or production. # Development specific
test: #
#
development:
adapter: mysql2 adapter: mysql2
encoding: utf8 encoding: utf8
reconnect: false reconnect: false
database: gitlabhq_test database: gitlabhq_development
pool: 5 pool: 5
username: root username: root
password: "secure password" password: "secure password"
# socket: /tmp/mysql.sock # socket: /tmp/mysql.sock
production: # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: &test
adapter: mysql2 adapter: mysql2
encoding: utf8 encoding: utf8
reconnect: false reconnect: false
database: gitlabhq_production database: gitlabhq_test
pool: 5 pool: 5
username: root username: root
password: "secure password" password: "secure password"
# socket: /tmp/mysql.sock # socket: /tmp/mysql.sock
cucumber:
<<: *test
#
# PRODUCTION
#
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 5
username: root
password: "secure password"
# socket: /tmp/mysql.sock
#
# Development specific
#
#
development: development:
adapter: mysql2 adapter: mysql2
encoding: utf8 encoding: utf8
...@@ -11,7 +29,7 @@ development: ...@@ -11,7 +29,7 @@ development:
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test: &test
adapter: mysql2 adapter: mysql2
encoding: utf8 encoding: utf8
reconnect: false reconnect: false
...@@ -21,12 +39,5 @@ test: ...@@ -21,12 +39,5 @@ test:
password: password:
# socket: /tmp/mysql.sock # socket: /tmp/mysql.sock
production: cucumber:
adapter: mysql2 <<: *test
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 5
username: root
password: "secure password"
# socket: /tmp/mysql.sock
#
# PRODUCTION
#
# SQLite version 3.x # SQLite version 3.x
# gem install sqlite3 # gem install sqlite3
# #
# Ensure the SQLite 3 gem is defined in your Gemfile # Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3' # gem 'sqlite3'
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
#
# Development specific
#
#
#
development: development:
adapter: sqlite3 adapter: sqlite3
database: db/development.sqlite3 database: db/development.sqlite3
...@@ -12,14 +27,11 @@ development: ...@@ -12,14 +27,11 @@ development:
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test: &test
adapter: sqlite3 adapter: sqlite3
database: db/test.sqlite3 database: db/test.sqlite3
pool: 5 pool: 5
timeout: 5000 timeout: 5000
production: cucumber:
adapter: sqlite3 <<: *test
database: db/production.sqlite3
pool: 5
timeout: 5000
Feature: Profile
Background:
Given I signin as a user
Scenario: I look at my profile
Given I visit profile page
Then I should see my profile info
Scenario: I change my password
Given I visit profile password page
Then I change my password
And I should be redirected to sign in page
Scenario: I reset my token
Given I visit profile token page
Then I reset my token
And I should see new token
Feature: Browse branches
Background:
Given I signin as a user
And I own project "Shop"
Given I visit project branches page
Scenario: I can see all git branches
Scenario: I can download project by branch
Scenario: I can view protected branches
Scenario: I can manage protected branches
Feature: Comment commit
Background:
Given I signin as a user
And I own project "Shop"
Given I visit project commit page
Scenario: I leave a comment for commit
Feature: Browse commits
Background:
Given I signin as a user
And I own project "Shop"
Given I visit project commits page
Scenario: I browse commits list for master branch
Then I see project commits
Scenario: I browse atom feed of commits list for master branch
Given I click atom feed link
Then I see commits atom feed
Scenario: I browse commit from list
Given I click on commit link
Then I see commit info
Scenario: I compare refs
Given I visit compare refs page
And I fill compare fields with refs
And I see compared refs
Feature: Browse tags
Background:
Given I signin as a user
And I own project "Shop"
Given I visit project tags page
Scenario: I can see all git tags
Scenario: I can download project by tag
Feature: Create Project
In order to get access to project sections
A user with ability to create a project
Should be able to create a new one
Scenario: User create a project
Given I signin as a user
When I visit new project page
And fill project form with valid data
Then I should see project page
And I should see empty project instuctions
Feature: Browse git repo
Background:
Given I signin as a user
And I own project "Shop"
Given I visit project source page
Scenario: I browse files from master branch
Then I should see files from repository
Scenario: I browse files for specific ref
Given I visit project source page for "8470d70"
Then I should see files from repository for "8470d70"
Scenario: I browse file content
Given I click on file from repo
Then I should see it content
Scenario: I browse raw file
Given I visit blob file from repo
And I click on raw button
Then I should see raw file content
@javascript
Feature: Project Wall
In order to use Project Wall
A user
Should be able to read & write messages
Background:
Given I signin as a user
And I own project "Shop"
And I visit project "Shop" wall page
Scenario: Write comment
Given I write new comment "my special test message"
Then I should see project wall note "my special test message"
Then I visit project "Shop" wall page
And I should see project wall note "my special test message"
Feature: Wiki
Background:
Given I signin as a user
And I own project "Shop"
Given I visit project wiki page
Scenario: Add new page
Given I create Wiki page
Then I should see newly created wiki page
Given /^I visit project source page$/ do
visit tree_project_ref_path(@project, @project.root_ref)
end
Then /^I should see files from repository$/ do
page.should have_content("app")
page.should have_content("History")
page.should have_content("Gemfile")
end
Given /^I visit project source page for "(.*?)"$/ do |arg1|
visit tree_project_ref_path(@project, arg1)
end
Then /^I should see files from repository for "(.*?)"$/ do |arg1|
current_path.should == tree_project_ref_path(@project, arg1)
page.should have_content("app")
page.should have_content("History")
page.should have_content("Gemfile")
end
Given /^I click on file from repo$/ do
click_link "Gemfile"
end
Then /^I should see it content$/ do
page.should have_content("rubygems.org")
end
Given /^I click on raw button$/ do
click_link "raw"
end
Given /^I visit blob file from repo$/ do
visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH)
end
Then /^I should see raw file content$/ do
page.source.should == ValidCommit::BLOB_FILE
end
Given /^I visit project commits page$/ do
visit project_commits_path(@project)
end
Then /^I see project commits$/ do
current_path.should == project_commits_path(@project)
commit = @project.commit
page.should have_content(@project.name)
page.should have_content(commit.message)
page.should have_content(commit.id.to_s[0..5])
end
Given /^I click atom feed link$/ do
click_link "Feed"
end
Then /^I see commits atom feed$/ do
commit = @project.commit
page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "Recent commits to #{@project.name}")
page.body.should have_selector("author email", :text => commit.author_email)
page.body.should have_selector("entry summary", :text => commit.message)
end
Given /^I click on commit link$/ do
visit project_commit_path(@project, ValidCommit::ID)
end
Then /^I see commit info$/ do
page.should have_content ValidCommit::MESSAGE
page.should have_content "Showing 1 changed file"
end
Given /^I visit compare refs page$/ do
visit compare_project_commits_path(@project)
end
Given /^I fill compare fields with refs$/ do
fill_in "from", :with => "master"
fill_in "to", :with => "stable"
click_button "Compare"
end
Given /^I see compared refs$/ do
page.should have_content "Commits (27)"
page.should have_content "Compare View"
page.should have_content "Showing 73 changed files"
end
Given /^I visit profile page$/ do
visit profile_path
end
Then /^I should see my profile info$/ do
page.should have_content "Profile"
page.should have_content @user.name
page.should have_content @user.email
end
Given /^I visit profile password page$/ do
visit profile_password_path
end
Then /^I change my password$/ do
fill_in "user_password", :with => "222333"
fill_in "user_password_confirmation", :with => "222333"
click_button "Save"
end
Then /^I should be redirected to sign in page$/ do
current_path.should == new_user_session_path
end
Given /^I visit profile token page$/ do
visit profile_token_path
end
Then /^I reset my token$/ do
@old_token = @user.private_token
click_button "Reset"
end
Then /^I should see new token$/ do
find("#token").value.should_not == @old_token
find("#token").value.should == @user.reload.private_token
end
include LoginMacros
Given /^I signin as a user$/ do
login_as :user
end
When /^I visit new project page$/ do
visit new_project_path
end
When /^fill project form with valid data$/ do
fill_in 'project_name', :with => 'NewProject'
fill_in 'project_code', :with => 'NPR'
fill_in 'project_path', :with => 'newproject'
click_button "Create project"
end
Then /^I should see project page$/ do
current_path.should == project_path(Project.last)
page.should have_content('NewProject')
end
Then /^I should see empty project instuctions$/ do
page.should have_content("git init")
page.should have_content("git remote")
page.should have_content(Project.last.url_to_repo)
end
Given /^I own project "(.*?)"$/ do |arg1|
@project = Factory :project, :name => arg1
@project.add_access(@user, :read, :write)
end
Given /^I visit project "(.*?)" wall page$/ do |arg1|
project = Project.find_by_name(arg1)
visit wall_project_path(project)
end
Then /^I should see project wall note "(.*?)"$/ do |arg1|
page.should have_content arg1
end
Given /^project "(.*?)" has comment "(.*?)"$/ do |arg1, arg2|
project = Project.find_by_name(arg1)
project.notes.create(:note => arg1, :author => project.users.first)
end
Given /^I write new comment "(.*?)"$/ do |arg1|
fill_in "note_note", :with => arg1
click_button "Add Comment"
end
Given /^I visit project wiki page$/ do
visit project_wiki_path(@project, :index)
end
Given /^I create Wiki page$/ do
fill_in "Title", :with => 'Test title'
fill_in "Content", :with => '[link test](test)'
click_on "Save"
end
Then /^I should see newly created wiki page$/ do
page.should have_content("Test title")
page.should have_content("link test")
click_link "link test"
page.should have_content("Editing page")
end
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require "selenium-webdriver"
require 'cucumber/rails'
require 'webmock/cucumber'
WebMock.allow_net_connect!
require Rails.root.join 'spec/monkeypatch'
require Rails.root.join 'spec/factories'
require Rails.root.join 'spec/support/login'
require Rails.root.join 'spec/support/valid_commit'
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector = :css
# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
#
# 1) Tag your scenario (or feature) with @allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
ActionController::Base.allow_rescue = false
# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
# See the DatabaseCleaner documentation for details. Example:
#
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
# # { :except => [:widgets] } may not do what you expect here
# # as tCucumber::Rails::Database.javascript_strategy overrides
# # this setting.
# DatabaseCleaner.strategy = :truncation
# end
#
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
# DatabaseCleaner.strategy = :transaction
# end
#
# Possible values are :truncation and :transaction
# The :transaction strategy is faster, but might give you threading problems.
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
Cucumber::Rails::Database.javascript_strategy = :truncation
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
begin
require 'cucumber/rake/task'
namespace :cucumber do
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
t.fork = true # You may get faster startup if you set this to false
t.profile = 'default'
end
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
t.profile = 'wip'
end
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
t.profile = 'rerun'
end
desc 'Run all features'
task :all => [:ok, :wip]
task :statsetup do
require 'rails/code_statistics'
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
end
end
desc 'Alias for cucumber:ok'
task :cucumber => 'cucumber:ok'
task :default => :cucumber
task :features => :cucumber do
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
end
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
task 'db:test:prepare' do
end
task :stats => 'cucumber:statsetup'
rescue LoadError
desc 'cucumber rake task not available (cucumber not installed)'
task :cucumber do
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
end
end
end
namespace :gitlab do
desc "GITLAB | Run both cucumber & rspec"
task :test => ['cucumber', 'spec']
end
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
#require 'spec_helper'
#require 'benchmark'
#
#describe "Projects" do
# before { login_as :user }
#
# describe "GET /projects/tree" do
# describe "head" do
# before do
# @project = Factory :project
# @project.add_access(@user, :read)
# end
#
# it "should be fast" do
# time = Benchmark.realtime do
# visit tree_project_ref_path(@project, @project.root_ref)
# end
# (time < 1.0).should be_true
# end
# end
#
# describe ValidCommit::ID do
# before do
# @project = Factory :project
# @project.add_access(@user, :read)
# end
#
# it "should be fast" do
# time = Benchmark.realtime do
# visit tree_project_ref_path(@project, ValidCommit::ID)
# end
# (time < 1.0).should be_true
# end
# end
# end
#end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment