# -*- encoding: utf-8 -*- require "spec_helper" describe FileManagerEngine do def initialize Article.destroy_all FileManager.destroy_all end it "works when association is one to many" do article1 = Article.create(title: "Título", path: "img1.jpg") FileManager.used_in("img1.jpg").count.should eq(1) article2 = Article.create(title: "Título 2", path: "img1.jpg") FileManager.used_in("img1.jpg")[0].should eq(article1) FileManager.used_in("img1.jpg")[1].should eq(article2) end it "works when association is many to many" do article1 = Article.create(title: "Título", path: ["img1.jpg", "img2.jpg"]) FileManager.used_in("img1.jpg").count.should eq(1) article2 = Article.create(title: "Título 2", path: ["img1.jpg", "img3.jpg"]) FileManager.used_in("img1.jpg")[0].should eq(article1) FileManager.used_in("img1.jpg")[1].should eq(article2) end end