Commit 30a69ce6 by John Doe

added remove_file specs

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