OSDN Git Service

Test if markdown is rendered properly.
authorMarin Jankovski <maxlazio@gmail.com>
Fri, 11 Oct 2013 11:44:00 +0000 (13:44 +0200)
committerMarin Jankovski <maxlazio@gmail.com>
Fri, 11 Oct 2013 11:44:00 +0000 (13:44 +0200)
features/project/source/markdown_render.feature [new file with mode: 0644]
features/steps/project/project_markdown_render.rb [new file with mode: 0644]
spec/lib/gitlab/satellite/merge_action_spec.rb
spec/models/project_spec.rb
spec/seed_project.tar.gz

diff --git a/features/project/source/markdown_render.feature b/features/project/source/markdown_render.feature
new file mode 100644 (file)
index 0000000..d461ae8
--- /dev/null
@@ -0,0 +1,70 @@
+Feature: Project markdown render
+  Background:
+    Given I sign in as a user
+    And I own project "Delta"
+    Given I visit project source page
+
+  Scenario: I browse files from master branch
+    Then I should see files from repository in master
+    And I should see rendered README which contains correct links
+    And I click on Gitlab API in README
+    Then I should see correct document rendered
+
+  Scenario: I view README in master branch
+    Then I should see files from repository in master
+    And I should see rendered README which contains correct links
+    And I click on Rake tasks in README
+    Then I should see correct directory rendered
+
+  Scenario: I navigate to doc directory to view documentation in master
+    And I navigate to the doc/api/README
+    And I see correct file rendered
+    And I click on users in doc/api/README
+    Then I should see the correct document file
+
+  Scenario: I navigate to doc directory to view user doc in master
+    And I navigate to the doc/api/README
+    And I see correct file rendered
+    And I click on raketasks in doc/api/README
+    Then I should see correct directory rendered
+
+  Scenario: I browse files from markdown branch
+    When I visit markdown branch
+    Then I should see files from repository in markdown branch
+    And I should see rendered README which contains correct links
+    And I click on Gitlab API in README
+    Then I should see correct document rendered for markdown branch
+
+  Scenario: I browse directory from markdown branch
+    When I visit markdown branch
+    Then I should see files from repository in markdown branch
+    And I should see rendered README which contains correct links
+    And I click on Rake tasks in README
+    Then I should see correct directory rendered for markdown branch
+
+  Scenario: I navigate to doc directory to view documentation in markdown branch
+    When I visit markdown branch
+    And I navigate to the doc/api/README
+    And I see correct file rendered in markdown branch
+    And I click on users in doc/api/README
+    Then I should see the users document file in markdown branch
+
+  Scenario: I navigate to doc directory to view user doc in markdown branch
+    When I visit markdown branch
+    And I navigate to the doc/api/README
+    And I see correct file rendered in markdown branch
+    And I click on raketasks in doc/api/README
+    Then I should see correct directory rendered for markdown branch
+
+  Scenario: I create a wiki page with different links
+    Given I go to wiki page
+    And I add various links to the wiki page
+    Then Wiki page should have added links
+    And I click on test link
+    Then I see new wiki page named test
+    When I go back to wiki page home
+    And I click on GitLab API doc link
+    Then I see Gitlab API document
+    When I go back to wiki page home
+    And I click on Rake tasks link
+    Then I see Rake tasks directory
diff --git a/features/steps/project/project_markdown_render.rb b/features/steps/project/project_markdown_render.rb
new file mode 100644 (file)
index 0000000..11a3ff9
--- /dev/null
@@ -0,0 +1,153 @@
+class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps
+  include SharedAuthentication
+  include SharedPaths
+
+  And 'I own project "Delta"' do
+    @project = Project.find_by_name "Delta"
+    @project ||= create(:project_with_code, name: "Delta", namespace: @user.namespace)
+    @project.team << [@user, :master]
+  end
+
+  Then 'I should see files from repository in master' do
+    current_path.should == project_tree_path(@project, "master")
+    page.should have_content "Gemfile"
+    page.should have_content "app"
+    page.should have_content "README"
+  end
+
+  And 'I should see rendered README which contains correct links' do
+    page.should have_content "Welcome to GitLab GitLab is a free project and repository management application"
+    page.should have_link "GitLab API doc"
+    page.should have_link "GitLab API website"
+    page.should have_link "Rake tasks"
+    page.should have_link "backup and restore procedure"
+  end
+
+  And 'I click on Gitlab API in README' do
+    click_link "GitLab API doc"
+  end
+
+  Then 'I should see correct document rendered' do
+    current_path.should == project_blob_path(@project, "master/doc/api/README.md")
+    page.should have_content "All API requests require authentication"
+  end
+
+  And 'I click on Rake tasks in README' do
+    click_link "Rake tasks"
+  end
+
+  Then 'I should see correct directory rendered' do
+    current_path.should == project_tree_path(@project, "master/doc/raketasks")
+    page.should have_content "backup_restore.md"
+    page.should have_content "maintenance.md"
+  end
+
+  And 'I navigate to the doc/api/README' do
+    click_link "doc"
+    click_link "api"
+    click_link "README.md"
+  end
+
+  And 'I see correct file rendered' do
+    current_path.should == project_blob_path(@project, "master/doc/api/README.md")
+    page.should have_content "Contents"
+    page.should have_link "Users"
+    page.should have_link "Rake tasks"
+  end
+
+  And 'I click on users in doc/api/README' do
+    click_link "Users"
+  end
+
+  Then 'I should see the correct document file' do
+    current_path.should == project_blob_path(@project, "master/doc/api/users.md")
+    page.should have_content "Get a list of users."
+  end
+
+  And 'I click on raketasks in doc/api/README' do
+    click_link "Rake tasks"
+  end
+
+  When 'I visit markdown branch' do
+    visit project_tree_path(@project, "markdown")
+  end
+
+  Then 'I should see files from repository in markdown branch' do
+    current_path.should == project_tree_path(@project, "markdown")
+    page.should have_content "Gemfile"
+    page.should have_content "app"
+    page.should have_content "README"
+  end
+
+  And 'I see correct file rendered in markdown branch' do
+    current_path.should == project_blob_path(@project, "markdown/doc/api/README.md")
+    page.should have_content "Contents"
+    page.should have_link "Users"
+    page.should have_link "Rake tasks"
+  end
+
+  Then 'I should see correct document rendered for markdown branch' do
+    current_path.should == project_blob_path(@project, "markdown/doc/api/README.md")
+    page.should have_content "All API requests require authentication"
+  end
+
+  Then 'I should see correct directory rendered for markdown branch' do
+    current_path.should == project_tree_path(@project, "markdown/doc/raketasks")
+    page.should have_content "backup_restore.md"
+    page.should have_content "maintenance.md"
+  end
+
+  Then 'I should see the users document file in markdown branch' do
+    current_path.should == project_blob_path(@project, "markdown/doc/api/users.md")
+    page.should have_content "Get a list of users."
+  end
+
+  Given 'I go to wiki page' do
+    click_link "Wiki"
+    current_path.should == project_wiki_path(@project, "home")
+  end
+
+  And 'I add various links to the wiki page' do
+    fill_in "wiki[content]", with: "[test](test)\n[GitLab API doc](doc/api/README.md)\n[Rake tasks](doc/raketasks)\n"
+    fill_in "wiki[message]", with: "Adding links to wiki"
+    click_button "Create page"
+  end
+
+  Then 'Wiki page should have added links' do
+    current_path.should == project_wiki_path(@project, "home")
+    page.should have_content "test GitLab API doc Rake tasks"
+  end
+
+  And 'I click on test link' do
+    click_link "test"
+  end
+
+  Then 'I see new wiki page named test' do
+    current_path.should ==  project_wiki_path(@project, "test")
+    page.should have_content "Editing page"
+  end
+
+  When 'I go back to wiki page home' do
+    visit project_wiki_path(@project, "home")
+    current_path.should == project_wiki_path(@project, "home")
+  end
+
+  And 'I click on GitLab API doc link' do
+    click_link "GitLab API"
+  end
+
+  Then 'I see Gitlab API document' do
+    current_path.should == project_blob_path(@project, "master/doc/api/README.md")
+    page.should have_content "Status codes"
+  end
+
+  And 'I click on Rake tasks link' do
+    click_link "Rake tasks"
+  end
+
+  Then 'I see Rake tasks directory' do
+    current_path.should == project_tree_path(@project, "master/doc/raketasks")
+    page.should have_content "backup_restore.md"
+    page.should have_content "maintenance.md"
+  end
+end 
\ No newline at end of file
index 3be1438..e40ff73 100644 (file)
@@ -3,7 +3,7 @@ require 'spec_helper'
 describe 'Gitlab::Satellite::MergeAction' do
   before(:each) do
 #    TestEnv.init(mailer: false, init_repos: true, repos: true)
-    @master = ['master', 'bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a']
+    @master = ['master', 'b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828']
     @one_after_stable = ['stable', '6ea87c47f0f8a24ae031c3fff17bc913889ecd00'] #this commit sha is one after stable
     @wiki_branch = ['wiki', '635d3e09b72232b6e92a38de6cc184147e5bcb41'] #this is the commit sha where the wiki branch goes off from master
     @conflicting_metior = ['metior', '313d96e42b313a0af5ab50fa233bf43e27118b3f'] #this branch conflicts with the wiki branch
index 47ae760..dcaee39 100644 (file)
@@ -132,17 +132,17 @@ describe Project do
 
     it "should close merge request if last commit from source branch was pushed to target branch" do
       @merge_request.reloaded_commits
-      @merge_request.last_commit.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
-      project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a", "refs/heads/stable", @key.user)
+      @merge_request.last_commit.id.should == "b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828"
+      project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828", "refs/heads/stable", @key.user)
       @merge_request.reload
       @merge_request.merged?.should be_true
     end
 
     it "should update merge request commits with new one if pushed to source branch" do
       @merge_request.last_commit.should == nil
-      project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a", "refs/heads/master", @key.user)
+      project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828", "refs/heads/master", @key.user)
       @merge_request.reload
-      @merge_request.last_commit.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
+      @merge_request.last_commit.id.should == "b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828"
     end
   end
 
index 3ffafed..7abb51e 100644 (file)
Binary files a/spec/seed_project.tar.gz and b/spec/seed_project.tar.gz differ