Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2011-10-09 01:36:38 +0400
committerDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2011-10-09 01:36:38 +0400
commite98c77857f9f765d1854b92c2dc33049504a596d (patch)
tree52fbfc1cdb55df21843965479c97be0c91121a9a /spec/support
parent0f43e98ef8c2da8908b1107f75b67cda2572c2c4 (diff)
init commitv0.9.4
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/js_patch.rb6
-rw-r--r--spec/support/login.rb29
-rw-r--r--spec/support/matchers.rb46
-rw-r--r--spec/support/security.rb0
-rw-r--r--spec/support/shared_examples.rb18
-rw-r--r--spec/support/valid_commit.rb25
6 files changed, 124 insertions, 0 deletions
diff --git a/spec/support/js_patch.rb b/spec/support/js_patch.rb
new file mode 100644
index 00000000000..0d4ab264e85
--- /dev/null
+++ b/spec/support/js_patch.rb
@@ -0,0 +1,6 @@
+module JsPatch
+ def confirm_js_popup
+ page.evaluate_script("window.alert = function(msg) { return true; }")
+ page.evaluate_script("window.confirm = function(msg) { return true; }")
+ end
+end
diff --git a/spec/support/login.rb b/spec/support/login.rb
new file mode 100644
index 00000000000..09f64f9e3c3
--- /dev/null
+++ b/spec/support/login.rb
@@ -0,0 +1,29 @@
+module LoginMacros
+ def login_as role
+ @user = User.create(:email => "user#{User.count}@mail.com",
+ :name => "John Smith",
+ :password => "123456",
+ :password_confirmation => "123456")
+
+ if role == :admin
+ @user.admin = true
+ @user.save!
+ end
+
+ visit new_user_session_path
+ fill_in "Email", :with => @user.email
+ fill_in "Password", :with => "123456"
+ click_button "Sign in"
+ end
+
+ def login_with(user)
+ visit new_user_session_path
+ fill_in "Email", :with => user.email
+ fill_in "Password", :with => "123456"
+ click_button "Sign in"
+ end
+
+ def logout
+ click_link "Logout" rescue nil
+ end
+end
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
new file mode 100644
index 00000000000..953b535698d
--- /dev/null
+++ b/spec/support/matchers.rb
@@ -0,0 +1,46 @@
+RSpec::Matchers.define :be_valid_commit do
+ match do |actual|
+ actual != nil
+ actual.id == ValidCommit::ID
+ actual.message == ValidCommit::MESSAGE
+ actual.author.name == ValidCommit::AUTHOR_FULL_NAME
+ end
+end
+
+RSpec::Matchers.define :be_allowed_for do |user|
+ match do |url|
+ include UrlAccess
+ url_allowed?(user, url)
+ end
+end
+
+RSpec::Matchers.define :be_denied_for do |user|
+ match do |url|
+ include UrlAccess
+ url_denied?(user, url)
+ end
+end
+
+module UrlAccess
+ def url_allowed?(user, url)
+ emulate_user(user)
+ visit url
+ result = (current_path == url)
+ end
+
+ def url_denied?(user, url)
+ emulate_user(user)
+ visit url
+ result = (current_path != url)
+ end
+
+ def emulate_user(user)
+ user = case user
+ when :user then Factory(:user)
+ when :visitor then nil
+ when :admin then Factory(:admin)
+ else user
+ end
+ login_with(user) if user
+ end
+end
diff --git a/spec/support/security.rb b/spec/support/security.rb
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/spec/support/security.rb
diff --git a/spec/support/shared_examples.rb b/spec/support/shared_examples.rb
new file mode 100644
index 00000000000..a2e94ac109b
--- /dev/null
+++ b/spec/support/shared_examples.rb
@@ -0,0 +1,18 @@
+shared_examples_for :project_side_pane do
+ subject { page }
+ it { should have_content((@project || project).name) }
+ it { should have_content("Commits") }
+ it { should have_content("Team") }
+ it { should have_content("Tree") }
+end
+
+
+shared_examples_for :tree_view do
+ subject { page }
+
+ it "should have Tree View of project" do
+ should have_content("app")
+ should have_content("history")
+ should have_content("Gemfile")
+ end
+end
diff --git a/spec/support/valid_commit.rb b/spec/support/valid_commit.rb
new file mode 100644
index 00000000000..a4d3496e241
--- /dev/null
+++ b/spec/support/valid_commit.rb
@@ -0,0 +1,25 @@
+module ValidCommit
+ ID = "eaffbe556ec3a8dc84ef15892a9f12d84dde7e1d"
+ MESSAGE = "style"
+ AUTHOR_FULL_NAME = "Dmitriy Zaporozhets"
+
+ FILES = [".gitignore", ".rspec", ".rvmrc", "Gemfile", "Gemfile.lock", "LICENSE", "README.rdoc", "Rakefile", "app", "config.ru", "config", "db", "doc", "lib", "log", "public", "script", "spec", "vendor"]
+ FILES_COUNT = 19
+
+ C_FILE_PATH = "app/models"
+ C_FILES = [".gitkeep", "project.rb", "user.rb"]
+
+ BLOB_FILE = <<-blob
+<div class="span-14 colborder">
+ <h2>Tree / <%= link_to "Commits", project_commits_path(@project) %></h2>
+ <%= render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @commit.tree} %>
+</div>
+
+<div class="span-8 right">
+ <%= render "side_panel" %>
+</div>
+blob
+
+ BLOB_FILE_PATH = "app/views/projects/show.html.erb"
+end
+