Bug fix: Save newly saved sequences under the correct folder

folders
Rick Carlino 2019-12-11 14:24:47 -06:00
parent f4b59ea0d5
commit 7f6449ece2
3 changed files with 14 additions and 1 deletions

View File

@ -12,6 +12,7 @@ module Sequences
optional do
color
args
integer :folder_id
end
def validate
@ -25,6 +26,7 @@ module Sequences
p = inputs
.merge(migrated_nodes: true)
.without(:body, :args, "body", "args")
.merge(folder: device.folders.find_by(id: folder_id))
seq = Sequence.create!(p)
x = CeleryScript::FirstPass.run!(sequence: seq,
args: args || {},

View File

@ -191,7 +191,7 @@ export class RawFolders extends React.Component<Props, State> {
onChange={({ currentTarget }) => { updateSearchTerm(currentTarget.value); }} />
<button onClick={this.toggleAll}>{this.state.toggleDirection ? "📂" : "📁"}</button>
<button onClick={() => createFolder()}>+📁</button>
<button title="+Sequence">+</button>
<button onClick={() => addNewSequenceToFolder(0)}>+</button>
<this.Graph />
{this.state.movedSequenceUuid && <FolderDropButton onClick={() => this.endSequenceMove(0)} />}
<ul>

View File

@ -18,6 +18,17 @@ describe Sequences::Create do
expect(Sequence.find(seq[:id]).device).to eq(device)
end
it "creates a sequence with a folder" do
folder = Folder.create!(name: "parent",
color: "red",
device: user.device)
seq = Sequences::Create.run!(device: device,
name: "X",
body: [],
folder_id: folder.id)
expect(folder.id).to eq(seq.fetch("folder_id"))
end
it 'Gives validation errors for malformed AST nodes' do
move_abs = body.select{ |x| x["kind"] == "move_absolute" }.first
move_abs["args"]["location"]["args"]["x"] = "not a number"