Comments (10)
I'm getting the same problem. I will investigate what causes this problem and let you know.
from boxroom.
I'm having a look as well. Will let you know if I get any fixed and get you a pull request.
from boxroom.
I'm getting less errors than you though. Seems some validations are not running. Very strange.
Run options: --seed 42811
# Running:
...............F..F....F..........E....F...F...................F.....
Finished in 1.883689s, 36.6303 runs/s, 134.3109 assertions/s.
1) Failure:
FolderTest#test_copy_a_folder [/Users/mischa/Sites/boxroom/test/unit/folder_test.rb:127]:
ActiveRecord::RecordInvalid expected but nothing was raised.
2) Failure:
FolderTest#test_move_a_folder [/Users/mischa/Sites/boxroom/test/unit/folder_test.rb:158]:
--- expected
+++ actual
@@ -1 +1 @@
-#<Folder id: 301, name: "Root folder", parent_id: nil, created_at: "2014-05-06 12:41:02", updated_at: "2014-05-06 12:41:02">
+#<Folder id: 286, name: "Root folder", parent_id: nil, created_at: "2014-05-06 12:41:02", updated_at: "2014-05-06 12:41:02">
3) Failure:
FolderTest#test_whether_a_folder_has_children_or_not [/Users/mischa/Sites/boxroom/test/unit/folder_test.rb:184]:
--- expected
+++ actual
@@ -1 +1 @@
-#<Folder id: 312, name: "Root folder", parent_id: nil, created_at: "2014-05-06 12:41:02", updated_at: "2014-05-06 12:41:02">
+#<Folder id: 286, name: "Root folder", parent_id: nil, created_at: "2014-05-06 12:41:02", updated_at: "2014-05-06 12:41:02">
4) Error:
ShareLinkTest#test_emails_is_not_longer_than_256_characters:
ActiveRecord::StatementInvalid: Mysql2::Error: Data too long for column 'emails' at row 1: UPDATE `share_links` SET `emails` = '[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]', `link_token` = '99a1e37c5942f11c2bbe', `updated_at` = '2014-05-06 12:41:02' WHERE `share_links`.`id` = 62
test/unit/share_link_test.rb:17:in `block in <class:ShareLinkTest>'
5) Failure:
UserFileTest#test_attachment_file_name_is_unique [/Users/mischa/Sites/boxroom/test/unit/user_file_test.rb:55]:
Failed assertion, no message given.
6) Failure:
UserFileTest#test_copy_a_file [/Users/mischa/Sites/boxroom/test/unit/user_file_test.rb:85]:
ActiveRecord::RecordInvalid expected but nothing was raised.
7) Failure:
UserTest#test_user_permissions [/Users/mischa/Sites/boxroom/test/unit/user_test.rb:101]:
Failed assertion, no message given.
69 runs, 253 assertions, 6 failures, 1 errors, 0 skips
from boxroom.
So, the issue with all of these errors except for #4 (the field length issue) appears to be related to this code in folder.rb:
83 def self.root
84 @root_folder ||= find_by_name_and_parent_id('Root folder', nil)
85 end
You are storing the root folder, once it is retrieved, presumably so that you don't hit the database the next time you access Folder.root. All fine and good in the working app.
However, the test db gets rolled back for each test, so the root folder is getting recreated each time FactoryGirl.create(:folder) is called. Apparently, SQLite3 resets the auto-increment counter on a table when a transaction is rolled back, but MySQL (and PostgreSQL, for that matter) does not. Because of this, each new creation of the root folder under MySQL gets a new ID number. The @root_folder instance variable never gets reset, it still refers to the first root folder that was created, including the original ID number, so in these tests you never get a match between the parent (current root folder) and the @root_folder value returned by the Folder#root method (original root folder).
This is proven out by adding the following at line 148 of folder_test.rb:
148 raise [Folder.where(:name => 'Root folder'), Folder.root].inspect
... and then running your tests. Look at the "move a folder" test results. You'll see a trace listing two folder objects with different ID's. This indicates that Folder.root holds an object that no longer resides in the db, otherwise they'd match.
Changing the code as such results in these test errors going away, further proving that this is the issue:
83 def self.root
84 find_by_name_and_parent_id('Root folder', nil)
85 end
However, that's not really a solution - the issue isn't really with the code, it's with the way the testing runs under MySQL. I'm not sure if this is the cleanest fix for this, but here's what I did.
I added the following class method to Folder:
def self.clear_root!
@root_folder = nil
end
And I added a setup step in the folder and userfile tests to call that method before each test to insure that the root_folder is valid for that test.
def setup
Folder.clear_root!
end
Sending you a pull request for all this. I also fixed the email too long issue on the ShareLink. Rails migrations on MySQL create string fields as VARCHAR(255), so I bumped the validation down from 256 to 255.
from boxroom.
I got less errors here at work as well - I'm not sure what the other three were about, but I will double-check them on home computer (where I was getting the original 10) tonight.
from boxroom.
Looking at the error differences, I believe that somewhere towards the end of debugging last night I may have run the install in TEST, which would account for those three additional "already taken" errors. Sorry about that.
from boxroom.
Since this is only used in test, instead of adding a clear_root!
class method to the Folder
class, I would prefer implementing setup
like this:
def setup
Folder.instance_variable_set('@root_folder', nil)
end
from boxroom.
Fair enough! Give me a few minutes and I'll update my pull branch.
from boxroom.
Done! I added a test_helper method to execute code as above, and called that helper from folder and userfile tests.
from boxroom.
Thanks for noticing this, finding out what was wrong and fixing it. I did one more commit to reflect the change from 256 char to 255 char in the UI as well: 4508f02
from boxroom.
Related Issues (20)
- Add custom message before send links HOT 3
- Add more infos to shared files HOT 6
- filename and filesize in the message send by email HOT 2
- Can be the emails sent from current user email ? HOT 3
- JSON::GeneratorError in Admins#new HOT 15
- can't preview the file ? HOT 1
- User Home Folder HOT 1
- Internal server error HOT 2
- turbolinks HOT 1
- bundle install fires anti-virus warning HOT 2
- no wiki? HOT 5
- User Authentication in Boxroom HOT 1
- new to rails 4.1, secret key. HOT 8
- Tagging for files and folders + search HOT 6
- Upload of 1,5 GByte zip file results in uploaded file being only 1,1 GByte in size HOT 6
- Cannot configure boxroom to send email invitations through gmail HOT 1
- Demo app HOT 1
- SyntaxError in FilesController#new HOT 2
- Can't See uploaded files.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boxroom.