summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/development/changelog.md2
-rw-r--r--doc/development/new_fe_guide/development/testing.md136
-rw-r--r--doc/gitlab-basics/start-using-git.md147
-rw-r--r--doc/user/project/quick_actions.md1
4 files changed, 253 insertions, 33 deletions
diff --git a/doc/development/changelog.md b/doc/development/changelog.md
index a9fa5ae834f..9e0c81b3d60 100644
--- a/doc/development/changelog.md
+++ b/doc/development/changelog.md
@@ -45,6 +45,8 @@ the `author` field. GitLab team members **should not**.
a changelog entry regardless of these guidelines if the contributor wants one.
Example: "Fixed a typo on the search results page. (Jane Smith)"
- Performance improvements **should** have a changelog entry.
+- Any change that introduces a database migration **must** have a
+ changelog entry.
## Writing good changelog entries
diff --git a/doc/development/new_fe_guide/development/testing.md b/doc/development/new_fe_guide/development/testing.md
index c359bd83ed1..e1e13474b75 100644
--- a/doc/development/new_fe_guide/development/testing.md
+++ b/doc/development/new_fe_guide/development/testing.md
@@ -1,3 +1,135 @@
-# Testing
+# Overview of Frontend Testing
-> TODO: Add content
+## Types of tests in our codebase
+
+* **RSpec**
+ * **[Ruby unit tests](#ruby-unit-tests-spec-rb)** for models, controllers, helpers, etc. (`/spec/**/*.rb`)
+ * **[Full feature tests](#full-feature-tests-spec-features-rb)** (`/spec/features/**/*.rb`)
+* **[Karma](#karma-tests-spec-javascripts-js)** (`/spec/javascripts/**/*.js`)
+* ~~Spinach~~ — These have been removed from our codebase in May 2018. (`/features/`)
+
+## RSpec: Ruby unit tests `/spec/**/*.rb`
+
+These tests are meant to unit test the ruby models, controllers and helpers.
+
+### When do we write/update these tests?
+
+Whenever we create or modify any Ruby models, controllers or helpers we add/update corresponding tests.
+
+---
+
+## RSpec: Full feature tests `/spec/features/**/*.rb`
+
+Full feature tests will load a full app environment and allow us to test things like rendering DOM, interacting with links and buttons, testing the outcome of those interactions through multiple pages if necessary. These are also called end-to-end tests but should not be confused with QA end-to-end tests (`package-and-qa` manual pipeline job).
+
+### When do we write/update these tests?
+
+When we add a new feature, we write at least two tests covering the success and the failure scenarios.
+
+### Relevant notes
+
+A `:js` flag is added to the test to make sure the full environment is loaded.
+
+```
+scenario 'successfully', :js do
+ sign_in(create(:admin))
+end
+```
+
+The steps of each test are written using capybara methods ([documentation](http://www.rubydoc.info/gems/capybara/2.15.1)).
+
+Bear in mind <abbr title="XMLHttpRequest">XHR</abbr> calls might require you to use `wait_for_requests` in between steps, like so:
+
+```rspec
+find('.form-control').native.send_keys(:enter)
+
+wait_for_requests
+
+expect(page).not_to have_selector('.card')
+```
+
+---
+
+## Karma tests `/spec/javascripts/**/*.js`
+
+These are the more frontend-focused, at the moment. They're **faster** than `rspec` and make for very quick testing of frontend components.
+
+### When do we write/update these tests?
+
+When we add/update a method/action/mutation to Vue or Vuex, we write karma tests to ensure the logic we wrote doesn't break. We should, however, refrain from writing tests that double-test Vue's internal features.
+
+### Relevant notes
+
+Karma tests are run against a virtual DOM.
+
+To populate the DOM, we can use fixtures to fake the generation of HTML instead of having Rails do that.
+
+Be sure to check the [best practices for karma tests](../../testing_guide/frontend_testing.html#best-practices).
+
+### Vue and Vuex
+
+Test as much as possible without double-testing Vue's internal features, as mentioned above.
+
+Make sure to test computedProperties, mutations, actions. Run the action and test that the proper mutations are committed.
+
+Also check these [notes on testing Vue components](../../fe_guide/vue.html#testing-vue-components).
+
+#### Vuex Helper: `testAction`
+
+We have a helper available to make testing actions easier, as per [official documentation](https://vuex.vuejs.org/en/testing.html):
+
+```
+testAction(
+ actions.actionName, // action
+ { }, // params to be passed to action
+ state, // state
+ [
+ { type: types.MUTATION},
+ { type: types.MUTATION_1, payload: {}},
+ ], // mutations committed
+ [
+ { type: 'actionName', payload: {}},
+ { type: 'actionName1', payload: {}},
+ ] // actions dispatched
+ done,
+);
+```
+
+Check an example in [spec/javascripts/ide/stores/actions_spec.jsspec/javascripts/ide/stores/actions_spec.js](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/spec/javascripts/ide/stores/actions_spec.js).
+
+#### Vue Helper: `mountComponent`
+
+To make mounting a Vue component easier and more readable, we have a few helpers available in `spec/helpers/vue_mount_component_helper`.
+
+* `createComponentWithStore`
+* `mountComponentWithStore`
+
+Examples of usage:
+
+```
+beforeEach(() => {
+ vm = createComponentWithStore(Component, store);
+
+ vm.$store.state.currentBranchId = 'master';
+
+ vm.$mount();
+},
+```
+
+```
+beforeEach(() => {
+ vm = mountComponentWithStore(Component, {
+ el: '#dummy-element',
+ store,
+ props: { badge },
+ });
+},
+```
+
+Don't forget to clean up:
+
+```
+afterEach(() => {
+ vm.$destroy();
+});
+```
diff --git a/doc/gitlab-basics/start-using-git.md b/doc/gitlab-basics/start-using-git.md
index 42cd8bb3e48..0d9994c9925 100644
--- a/doc/gitlab-basics/start-using-git.md
+++ b/doc/gitlab-basics/start-using-git.md
@@ -17,112 +17,197 @@ Depending on your operating system, you will need to use a shell of your prefere
Git is usually preinstalled on Mac and Linux.
Type the following command and then press enter:
-```
+
+```bash
git --version
```
-You should receive a message that will tell you which Git version you have on your computer. If you don’t receive a "Git version" message, it means that you need to [download Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
+You should receive a message that tells you which Git version you have on your computer. If you don’t receive a "Git version" message, it means that you need to [download Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
If Git doesn't automatically download, there's an option on the website to [download manually](https://git-scm.com/downloads). Then follow the steps on the installation window.
-After you are finished installing, open a new shell and type "git --version" again to verify that it was correctly installed.
+After you are finished installing Git, open a new shell and type `git --version` again to verify that it was correctly installed.
## Add your Git username and set your email
-It is important to configure your Git username and email address as every Git commit will use this information to identify you as the author.
+It is important to configure your Git username and email address, since every Git commit will use this information to identify you as the author.
On your shell, type the following command to add your username:
-```
+
+```bash
git config --global user.name "YOUR_USERNAME"
```
Then verify that you have the correct username:
-```
+
+```bash
git config --global user.name
```
To set your email address, type the following command:
-```
+
+```bash
git config --global user.email "your_email_address@example.com"
```
To verify that you entered your email correctly, type:
-```
+
+```bash
git config --global user.email
```
-You'll need to do this only once as you are using the `--global` option. It tells Git to always use this information for anything you do on that system. If you want to override this with a different username or email address for specific projects, you can run the command without the `--global` option when you’re in that project.
+You'll need to do this only once, since you are using the `--global` option. It tells Git to always use this information for anything you do on that system. If you want to override this with a different username or email address for specific projects, you can run the command without the `--global` option when you’re in that project.
## Check your information
-To view the information that you entered, type:
-```
+To view the information that you entered, along with other global options, type:
+
+```bash
git config --global --list
```
+
## Basic Git commands
### Go to the master branch to pull the latest changes from there
-```
+```bash
git checkout master
```
### Download the latest changes in the project
-This is for you to work on an up-to-date copy (it is important to do every time you work on a project), while you setup tracking branches.
+
+This is for you to work on an up-to-date copy (it is important to do this every time you start working on a project), while you set up tracking branches. You pull from remote repositories to get all the changes made by users since the last time you cloned or pulled the project. Later, you can push your local commits to the remote repositories.
+
+```bash
+git pull REMOTE NAME-OF-BRANCH
```
-git pull REMOTE NAME-OF-BRANCH -u
+
+When you first clone a repository, REMOTE is typically "origin". This is where the repository came from, and it indicates the SSH or HTTPS URL of the repository on the remote server. NAME-OF-BRANCH is usually "master", but it may be any existing branch.
+
+### View your remote repositories
+
+To view your remote repositories, type:
+
+```bash
+git remote -v
```
-(REMOTE: origin) (NAME-OF-BRANCH: could be "master" or an existing branch)
### Create a branch
-Spaces won't be recognized, so you will need to use a hyphen or underscore.
-```
+
+To create a branch, type the following (spaces won't be recognized in the branch name, so you will need to use a hyphen or underscore):
+
+```bash
git checkout -b NAME-OF-BRANCH
```
-### Work on a branch that has already been created
-```
+### Work on an existing branch
+
+To switch to an existing branch, so you can work on it:
+
+```bash
git checkout NAME-OF-BRANCH
```
### View the changes you've made
-It's important to be aware of what's happening and what's the status of your changes.
-```
+
+It's important to be aware of what's happening and the status of your changes. When you add, change, or delete files/folders, Git knows about it. To check the status of your changes:
+
+```bash
git status
```
-### Add changes to commit
-You'll see your changes in red when you type "git status".
+### View differences
+
+To view the differences between your local, unstaged changes and the repository versions that you cloned or pulled, type:
+
+```bash
+git diff
+```
+
+### Add and commit local changes
+
+You'll see your local changes in red when you type `git status`. These changes may be new, modified, or deleted files/folders. Use `git add` to stage a local file/folder for committing. Then use `git commit` to commit the staged files:
+
+```bash
+git add FILE OR FOLDER
+git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
```
-git add CHANGES IN RED
-git commit -m "DESCRIBE THE INTENTION OF THE COMMIT"
+
+### Add all changes to commit
+
+To add and commit all local changes in one command:
+
+```bash
+git add .
+git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
```
+NOTE: **Note:**
+The `.` character typically means _all_ in Git.
+
### Send changes to gitlab.com
-```
+
+To push all local commits to the remote repository:
+
+```bash
git push REMOTE NAME-OF-BRANCH
```
-### Delete all changes in the Git repository, but leave unstaged things
+For example, to push your local commits to the _master_ branch of the _origin_ remote:
+
+```bash
+git push origin master
```
+
+### Delete all changes in the Git repository
+
+To delete all local changes in the repository that have not been added to the staging area, and leave unstaged files/folders, type:
+
+```bash
git checkout .
```
-### Delete all changes in the Git repository, including untracked files
-```
+### Delete all untracked changes in the Git repository
+
+```bash
git clean -f
```
+### Unstage all changes that have been added to the staging area
+
+To undo the most recent add, but not committed, files/folders:
+
+```bash
+git reset .
+```
+
+### Undo most recent commit
+
+To undo the most recent commit, type:
+
+```bash
+git reset HEAD~1
+```
+
+This leaves the files and folders unstaged in your local repository.
+
+CAUTION: **Warning:**
+A Git commit is mostly irreversible, particularly if you already pushed it to the remote repository. Although you can undo a commit, the best option is to avoid the situation altogether.
+
### Merge created branch with master branch
+
You need to be in the created branch.
-```
+
+```bash
git checkout NAME-OF-BRANCH
git merge master
```
### Merge master branch with created branch
+
You need to be in the master branch.
-```
+
+```bash
git checkout master
git merge NAME-OF-BRANCH
```
diff --git a/doc/user/project/quick_actions.md b/doc/user/project/quick_actions.md
index 2f4ed3493c2..0ef8eddad20 100644
--- a/doc/user/project/quick_actions.md
+++ b/doc/user/project/quick_actions.md
@@ -42,3 +42,4 @@ do.
| `/tableflip` | Append the comment with `(╯°□°)╯︵ ┻━┻` |
| `/shrug` | Append the comment with `¯\_(ツ)_/¯` |
| <code>/copy_metadata #issue &#124; !merge_request</code> | Copy labels and milestone from other issue or merge request |
+| `/confidential` | Makes the issue confidential | \ No newline at end of file