Commit 30a69ce6 by John Doe

added remove_file specs

parent 666623f8
AllCops:
TargetRubyVersion: 2.3
Include:
- '**/config.ru'
......
......@@ -48,6 +48,10 @@ group :development, :test do
end
group :development do
gem 'guard-rubocop'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
......
......@@ -73,6 +73,9 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
guard-rubocop (1.2.0)
guard (~> 2.0)
rubocop (~> 0.20)
i18n (0.7.0)
jbuilder (2.4.1)
activesupport (>= 3.0.0, < 5.1)
......@@ -223,6 +226,7 @@ DEPENDENCIES
coffee-rails (~> 4.1.0)
guard
guard-rspec
guard-rubocop
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.6)
......
......@@ -70,3 +70,8 @@ guard :rspec, cmd: "bin/rspec" do
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
end
end
guard :rubocop do
watch(%r{.+\.rb$})
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
# frozen_string_literal: true
# application controller
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
......
# frozen_string_literal: true
# Controller for DbFiles
class DbFilesController < ApplicationController
end
# frozen_string_literal: true
# Controller for DbFolders
class DbFoldersController < ApplicationController
end
# frozen_string_literal: true
# controller for DbStreams
class DbStreamsController < ApplicationController
end
# frozen_string_literal: true
# A file in the database, contains one or more Streams
class DbFile < ActiveRecord::Base
belongs_to :db_folder
has_many :streams
def remove(db_service:)
db_service.remove_file(path)
destroy
end
end
# frozen_string_literal: true
# a folder in the database, may contain one or more DbFiles as files
# and one or more DbFolders as subfolders
class DbFolder < ActiveRecord::Base
......
# frozen_string_literal: true
# a stream in the database, this is the lowest element
# in the db hierarchy and contains actual data
class DbStream < ActiveRecord::Base
......
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
......
class AddPathToDbFiles < ActiveRecord::Migration
def change
add_column :db_files, :path, :string
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160516000545) do
ActiveRecord::Schema.define(version: 20160516024809) do
create_table "db_files", force: :cascade do |t|
t.string "name"
......@@ -19,6 +19,7 @@ ActiveRecord::Schema.define(version: 20160516000545) do
t.integer "db_folder_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "path"
end
create_table "db_folders", force: :cascade do |t|
......
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe DbFilesController, type: :controller do
......
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe DbFoldersController, type: :controller do
......
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe DbStreamsController, type: :controller do
......
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'DbFile' do
......@@ -7,4 +8,17 @@ RSpec.describe 'DbFile' do
specify { expect(db_file).to respond_to(:description) }
specify { expect(db_file).to respond_to(:streams) }
end
describe 'remove' do
let(:db_file) { DbFile.create }
let(:db_service) { double(remove_file: true) }
it 'destroys itself' do
db_file.remove(db_service: db_service)
expect(db_file).to be_destroyed
end
it 'removes itself from the remote system using DbService' do
db_file.remove(db_service: db_service)
expect(db_service).to have_received(:remove_file)
end
end
end
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'DbFolder' do
......
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'DbStream' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment