Eating a lot of sugar can cause large spikes and drops in blood sugar which can contribute to mood swing-like symptoms and low feelings during the drops, but the sugar alone is not the problem. Though maintaining a stable blood sugar level does help keep you well overall.
High sugar intake can cause spikes in blood glucose levels, the resulting sugar 'crash' can result in feelings of lethargy which may add to depressive feelings.
Yes, sugar affects depression. One soda equals 10 tsps. of sugar and caffeine(1/2 cup coffee). Initially there's a sugar "rush" then level drops in one hour. This becomes addictive cycle.
Withdrawal symptoms may occur from not eating sugar, thus worsening the depression. Controversial studies suggest that artificial sweeteners from diet sodas may have severe effects on people with mental issues.