42IN13SAh/Ivy — pull request #65 by slemmen (2014-12-15 00:41:59+00:00)
Title: S10-T01: Being able to save files

De story is: "Als gebruiker wil ik op een knop (en eventueel een hotkey) kunnen drukken zodat ik mijn broncode lokaal kan opslaan". De taak (T01) was alleen voor de hotkey, maar ik heb hier _OOK_ een menu item toegevoegd (technisch gezien voldoet het niet aan de story dan aangezien er een knop verwacht werd, maar aangezien ik die criteria heb verzonnen en dit ook prima vindt, is het zo wel goed).

Let bij reviewen aub. op code helderheid (zijn comments nodig?) en op structuur (hoort code die nu bijv. in een view staan niet in een controller?).

Dan nu alle informatie voor het testen:

# What to do when?
| | No existing file | Existing file |
|---------|------------------|------------------------|
| Save | Save as new file | Save the existing file |
| Save as | Save as new file | Save as new file |

# Where to start with dialog?
| | No existing file | Existing file |
|---------|-----------------------|---------------------------|
| Save | Ivy default directory | N/A |
| Save as | Ivy default directory | Existing file's directory |

# TestCases:
## 1. Save new file via save
### Steps:
- Type the following code in the editor:
```javascript
var x = 1;
```
- Press ctrl + s (no need to actually save the file yet)

### Expected output:
- [ ] If this was the first save operation I have ever ran, I should now have an Ivy directory in (windows: C:/Users/< username >/My Documents/Ivy, Linux: usr/home/Ivy, OSX: ??)
- [ ] I get prompted for a save file location
- [ ] The starting dir of the dialog is the Ivy folder that always get's created in the user's documents dir (windows: C:/Users/< username >/My Documents/Ivy, Linux: usr/home/Ivy, OSX: ??)

### Actions to do after test:
- Delete the file (if you actually did save)
- Create new file in the IDE
- Repeat the test, but now use the save function in menu > file instead of ctrl + s

## 2. Save existing file via save
### Steps:
- Type the following code in the editor:
```javascript
var x = 1;
```
- Press ctrl + s or use the save function in menu > file
- Save the file in some location, doesn't matter where
- Change the code, doesn't matter to what
- Press ctrl + s

### Expected output:
- [ ] If this was the first save operation I have ever ran, I should now have an Ivy directory in (windows: C:/Users//My Documents/Ivy, Linux: usr/home/Ivy, OSX: ??)
- [ ] I do not get prompted for a save file location
- [ ] The file changed to the new code

### Actions to do after test:
- Delete the file
- Create new file in the IDE
- Repeat the test, but now use the save function in menu > file instead of ctrl + s

## 3. Save new file via save as
### Steps:
- Type the following code in the editor:
```javascript
var x = 1;
```
- Go to menu >file > click save as

### Expected output:
- [ ] If this was the first save operation I have ever ran, I should now have an Ivy directory in (windows: C:/Users//My Documents/Ivy, Linux: usr/home/Ivy, OSX: ??)
- [ ] I get prompted for a save file location
- [ ] The starting dir of the dialog is the Ivy folder that always get's created in the user's documents dir (works cross-platform)

### Actions to do after test:
- Delete the file (if you actually did save)
- Create new file in the IDE

## 4. Save existing file via save as
### Steps:
- Type the following code in the editor:
```javascript
var x = 1;
```
- Press ctrl + s, use the save function in menu > file or use the save as function
- Save the file in a location that is _NOT_ the default dir
- Go to menu >file > click save as

### Expected output:
- [ ] If this was the first save operation I have ever ran, I should now have an Ivy directory in (windows: C:/Users//My Documents/Ivy, Linux: usr/home/Ivy, OSX: ??)
- [ ] I get prompted for a save file location
- [ ] The starting dir of the dialog is the folder that the existing file is located in (or the Ivy dir if the existing file has been deleted in between saves)

### Actions to do after test:
- Delete the file
- Create new file in the IDE

## 5. Don't save a new file
### Steps:
- Type the following code in the editor:
```javascript
var foo = "I should not be saved!";
```
- Press ctrl + s, use the save function in menu > file or use the save as function
- Click cancel in the dialog

### Expected output:
- [ ] If this was the first save operation I have ever ran, I should now have an Ivy directory in (windows: C:/Users//My Documents/Ivy, Linux: usr/home/Ivy, OSX: ??)
- [ ] There is no new .ivy file anywhere (i.e. not in the default Ivy dir)

### Actions to do after test:
- Create new file in the IDE

## 6. Don't save an existing file
### Steps:
- Type the following code in the editor:
```javascript
var x = 1;
```
- Press ctrl + s, use the save function in menu > file or use the save as function
- Save the file in some location, doesn't matter where
- Change the code, I suggest to:
```javascript
var foo = "I should not be saved!";
```
- Go to menu >file > click save as
- Click cancel in the dialog

### Expected output:
- [ ] If this was the first save operation I have ever ran, I should now have an Ivy directory in (windows: C:/Users//My Documents/Ivy, Linux: usr/home/Ivy, OSX: ??)
- [ ] The contents of the saved file are equal to the old code:
```javascript
var x = 1;
```

### Actions to do after test:
- Delete the file
- Create new file in the IDE

## 7. Save existing file that has been deleted
### Steps:
- Type the following code in the editor:
```javascript
var x = 1;
```
- Press ctrl + s, use the save function in menu > file or use the save as function
- Save the file in a location that is _NOT_ the default dir
- Change the code, doesn't matter to what (don't save yet!)
- Delete the saved file
- Press ctrl + s

### Expected output:
- [ ] If this was the first save operation I have ever ran, I should now have an Ivy directory in (windows: C:/Users//My Documents/Ivy, Linux: usr/home/Ivy, OSX: ??)
- [ ] I get prompted for a save file location
- [ ] The starting dir of the dialog is the Ivy folder that always get's created in the user's documents dir (windows: C:/Users/< username >/My Documents/Ivy, Linux: usr/home/Ivy, OSX: ??)
- [ ] There is no file that has the same name as the old file after the last save in the old folder (i.e. the file does not get automatically re-created)

### Actions to do after test:
- Create new file in the IDE
- Repeat the test, but now use the save function in menu > file instead of ctrl + s

txt file van bovenstaande testcases is [hier](https://dl.dropboxusercontent.com/u/39722120/ivy%20save%20testcases.txt) te downloaden, verander gewoon de \- [ ] in \- [X] om een expected als done te markeren (of verzin zelf iets creatiefs).

Review voor: @TimManders en @tmsburgt